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.ccApiProduct.getUrlFor

Returns a map where each entry associates a product'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.ccLogicProductUrlFor

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

Include one of the following keys. If none of these keys are included, the method returns a ccrz.ccApi.MissingInputException.

ccrz.ccApiProduct.PRODUCTIDLIST
List<String> of Salesforce IDs for specific products whose friendly URLs you want to return.
ccrz.ccApiProduct.PRODUCTLIST
List<Map<String, Object>>, where each Map<String, Object> represents a ccrz__E_Product__c whose friendly URL you want to return.
ccrz.ccApiProduct.PRODUCTSKULIST
List<String> of specific product SKUs whose friendly URLs you want to return.

This method checks for these keys in the following order of precedence:

  1. ccrz.ccApiProduct.PRODUCTLIST
  2. ccrz.ccApiProduct.PRODUCTSKULIST
  3. ccrz.ccApiProduct.PRODUCTIDLIST

Note

Inputs (Optional)

The input map can also include the following keys:

ccrz.ccApiProduct.PRODUCTLOCALE
String that specifies one of your storefront's supported locales. The method returns internationalized friendly URL values in the ccrz.ccApiProduct.PRODUCTURLMAP return key.

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

Note

ccrz.ccApiProduct.PRODUCTLOCALES
Set<String> of your storefront's supported locales. The method returns internationalized friendly URL values for the locales.
ccrz.ccApiProduct.STOREFRONT
String that specifies the name of a storefront for filtering the query.

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.ccApiProduct.PRODUCTURLMAP
Map<String, Object> for a single locale, where each key is a product ID and each value is the product's friendly URL.

Example

Query a pair of product IDs and return their friendly URL values.

try{
    // Gather set of products
    Map<String, Object> productReturnData = ccrz.ccApiProduct.fetch(new Map<String, Object>{
        ccrz.ccApi.API_VERSION => ccrz.ccApi.CURRENT_VERSION,
        ccrz.ccApiProduct.PRODUCTIDLIST => new List<String>{'Product_ID_1', 'Product_ID_2'},
        ccrz.ccApiProduct.ENTITYNAME => new Map<String, Object>{
            ccrz.ccAPI.SZ_DATA => ccrz.ccAPI.SZ_S,
            ccrz.ccAPI.SZ_ASSC => false,
            ccrz.ccAPI.SZ_REL => new List<String>{'Product_Item_I18Ns__r'}
        }
    });
 
    // Pass products to getUrlFor
    Map<String, Object> urlReturnData = ccrz.ccApiProduct.getUrlFor(new Map<String, Object>{
        ccrz.ccApi.API_VERSION => ccrz.ccApi.CURRENT_VERSION,
        ccrz.ccApiProduct.PRODUCTLIST => productReturnData.get(ccrz.ccApiProduct.PRODUCTLIST)
    });
 
    // Grab the URL map from the return data
    Map<String, Object> productUrlMap = (Map<String, Object>)urlReturnData.get(ccrz.ccApiProduct.PRODUCTURLMAP);
     
} catch(Exception e){
    // Error handling
}