ccrz.ccApiCategory.getUrlFor

Returns a map where each entry associates a category's ID with its friendly URL.

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> getUrlFor(Map<String, Object>)

Service Layer Classes

Logic Service Provider
ccrz.ccLogicCategoryUrlFor

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

ccrz.ccApiCategory.CATEGORYIDLIST
List<String> of Salesforce IDs for categories whose URLs you want to return.

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

Note

Inputs (Optional)

The input map can also include the following keys:

ccrz.ccApiCategory.CATEGORYLOCALE
String that specifies one of your storefront's supported locales.

If the input data doesn't include this key, the method falls back to ccrz.cc_CallContext.userLocale.

Note

ccrz.ccApiCategory.CATEGORYLOCALES
Set<String> of your storefront's supported locales.
ccrz.ccApiCategory.STOREFRONT
String that specifies the name of a storefront.

If the input data doesn't include this key, the method falls back to ccrz.cc_CallContext.storefront.

Note

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.ccApiCategory.CATEGORYURLMAP
Map<String, Object> for a single locale, where each key is a category ID and each value is the category's friendly URL.
ccrz.ccApiCategory.LOCALECATEGORYURLMAP
Map<String, Map<String, Object>> for multiple locales, where:
  • The outer map is keyed by category ID.
  • Each inner map is keyed by locale.
  • Each inner map's value is the category's friendly URL for the locale.
ccrz.ccApiCategory.LOCALESITEINDICES
Map<String, Map<String, Object>> for multiple locales, where:
  • The outer map is keyed by category ID.
  • Each inner map is keyed by locale.
  • Each inner map's value is the category's corresponding ccrz__E_SiteIndex__c record for the locale.
ccrz.ccApiCategory.SITEINDICES
Map<String, Object> for a single locale, where each key is a category ID and each value is the corresponding ccrz__E_SiteIndex__c record.

Example

Return the site indexes for a pair of category IDs.

try{
    // Pass category IDs to the ccrz.ccApiCategory.getUrlFor method
    Map<String, Object> categoryURLsToReturn = ccrz.ccApiCategory.getUrlFor(new Map<String, Object>{
        ccrz.ccApi.API_VERSION => ccrz.ccApi.CURRENT_VERSION,
        ccrz.ccApiCategory.CATEGORYIDLIST => new List<String>{'Category_ID_1', 'Category_ID_2'}
    });
 
    // Get the map of site indexes from the return data
    Map<String, Object> categorySiteIndices = categoryURLsToReturn.get(ccrz.ccApiCategory.SITEINDICES);
     
}catch(Exception e){
    // Error handling
}