Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.

ccrz.ccApiConfig.fetch

Executes a SOQL query of storefront configuration data and returns the matching content as Apex or JSON strings.

Compatibility

This reference applies to:

Release Managed Package Version API Version
B2B Commerce for Visualforce Winter ’21 4.13 12
B2B Commerce for Visualforce Spring ’20 4.12 11
B2B Commerce for Visualforce Summer ’19 4.11 10
B2B Commerce for Visualforce Spring ’19 4.10 9
B2B Commerce for Visualforce Summer ’18 4.9 8

You can still call older versions of the API for this method, which can accept different input keys or return different output keys. Any differences in behavior for older versions aren't documented in this topic.

Note

Signature

global static Map<String, Object> fetch(Map<String, Object>)

Service Layer Classes

This method doesn't support service layer extensions or overrides.

Inputs (Required)

Map<String, Object> that must include the following required keys:

ccrz.ccApi.API_VERSION
The version of the B2B Commerce for Visualforce API to reference for the method call. We recommend that you use the ccrz.ccApi.CURRENT_VERSION constant whenever possible, and only reference a specific version for compatibility if necessary.

If this key isn't specified, the method returns a ccrz.ccApi.NoApiVersionException.

Note

Inputs (Optional)

The input map can also include the following keys:

ccrz.ccApiConfig.CONFIG_MODULE
String that specifies the name of a specific module whose configuration data you want to return. Use the module's API name, such as ct for the Category Tree module or pl for the Product List module.
ccrz.ccApiConfig.CONFIG_MODULE => 'ct'
ccrz.ccApiConfig.EXTERNALLY_SAFE
Boolean
Value Usage
true Return configuration data that have the Externally Safe metadata field enabled.
false (default) Return all configuration data that match your query.
ccrz.ccApiConfig.PAGE_NAME
String that specifies the name of a page. The method returns only the configuration data that exist for that page. Use the page keys defined in CC Admin global settings, such as hp for Home page and plp for Product List page.
ccrz.ccApiConfig.PAGE_NAME => 'hp'

If you don't include this key, the method returns configuration data for all pages.

Note

ccrz.ccApiConfig.RETURN_SERIAL
Boolean
Value Usage
true Return configuration data as a serialized JSON string.
false (default) Return configuration data as an Apex List<Map<String, String>>.
ccrz.ccApiConfig.STORE_NAME
String that specifies the name of a storefront.

If you don't include this key, the method returns configuration data that are global and apply to all storefronts.

Note

ccrz.ccApiConfig.USE_CACHE
Boolean
Value Usage
true (default) Return configuration data cached in records of the ccrz__E_PublicCache__c and ccrz__E_PrivateCache__c objects.
false Return configuration data directly from records of the ccrz__E_Configuration__c object.

Outputs

Map<String, Object> that can include the following keys:

ccrz.ccApi.API_VERSION
Integer that indicates which API version was used for the query.
ccrz.ccApi.SUCCESS
Boolean
Value Usage
true The call completed.
false The call encountered errors.

B2B Commerce for Visualforce doesn't always return an exception for any errors that can occur. When this value is false, consider rolling back the API transaction to a previous savepoint.

Tip

ccrz.ccApiConfig.CONFIGURATIONS
List<Map<String, String>>, where each Map<String, String> represents a configuration record. The key value for each configuration record returned is moduleAPIname.configurationAPIname, such as ct.enabled.

To return serialized JSON instead of Map<String, String>, include ccrz.ccApiConfig.RETURN_SERIAL => true in the input map.

Tip

Example

Query configurations cached for the Home page in the DefaultStore and that have the Externally Safe metadata field enabled.

Map<String,Object> homePageConfigQuery = new Map<String,Object>{
    ccrz.ccApi.API_VERSION => ccrz.ccAPI.CURRENT_VERSION,
    ccrz.ccApiConfig.EXTERNALLY_SAFE => true,
    ccrz.ccApiConfig.USE_CACHE => true,
    ccrz.ccApiConfig.STORE_NAME => 'DefaultStore',
    ccrz.ccApiConfig.PAGE_NAME => 'hp'
};
 
try {  
    Map<String,Object> homePageConfigs = ccrz.ccApiConfig.fetch(homePageConfigQuery);
    Map<String,String> homePageConfigValues = (Map<String,String>)homePageConfigs.get(ccrz.ccApiConfig.CONFIGURATIONS);
} catch (Exception e) {
    // Error handling...
}