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.ccApiSeller.fetch

Executes a SOQL query of seller records, and returns a list of sellers that match your query.

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

Data Service Provider
ccrz.ccServiceSeller

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.ccApi.API_SIZING
Map<String, Object> that specifies the scope of data that this method returns, including which fields the method returns for each record that matches the query.
ccrz.ccApiSeller.PARAM_BY_ASC
Boolean
Value Usage
true Sort returned sellers by name in alphabetical order.
false Sort returned sellers by name in reverse alphabetical order.
ccrz.ccApiSeller.PARAM_BY_DIST
Boolean
Value Usage
true Sort returned sellers by distance, from nearest to farthest.
false Sort returned sellers by name.
ccrz.ccApiSeller.PARAM_ORIGIN_LAT
Decimal that specifies a seller location's latitude value to query by.
ccrz.ccApiSeller.PARAM_ORIGIN_LNG
Decimal that specifies a seller location's longitude value to query by.
ccrz.ccApiSeller.PARAM_SEARCH_DIST
Decimal that specifies a radius around the ccrz.ccApiSeller.PARAM_ORIGIN_LAT and ccrz.ccApiSeller.PARAM_ORIGIN_LNG location values.
ccrz.ccApiSeller.PARAM_SEARCH_UNIT
String that specifies the units of the ccrz.ccApiSeller.PARAM_SEARCH_DIST location radius, such as mi or km.
ccrz.ccApiSeller.SELLERID
String that specifies a seller ID to query.
ccrz.ccApiSeller.SELLERIDLIST
Set<String> of specific seller IDs to query.
new Set<String>{'Seller_ID_1', 'Seller_ID_2'}
ccrz.ccApiSeller.SELLERLOCALE
String that specifies a locale that you want to return localized seller values for in the ccrz.ccApiSeller.SELLERLIST return key. The service layer translates the values from ccrz__E_SellerI18N__c records and handles fallback languages, if necessary.

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

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.ccApiSeller.SELLERLIST
List<Map<String, Object>>, where each Map<String, Object> represents a seller record.

Example

Pass in a pair of seller IDs and capture the seller names in a string variable.

Set<String> sellerIdList = new Set<String>{'Seller_ID_1', 'Seller_ID_2'};
 
Map<String, Object> inputData = new Map<String, Object>{
    ccrz.ccApi.API_VERSION => ccrz.ccApi.CURRENT_VERSION,
    ccrz.ccApiSeller.SELLERIDLIST => sellerIdList,
    ccrz.ccApiSeller.SELLERLOCALE => 'fr_CA',
    ccrz.ccApi.SIZING => new Map<String, Object>{
        ccrz.ccApiSeller.ENTITYNAME => new Map<String, Object>{
            ccrz.ccApi.SZ_DATA => ccrz.ccApi.SZ_S
        }
    }
};
 
try {
    Map<String, Object> outputData = ccrz.ccApiSeller.fetch(inputData);
    if (outputData.get(ccrz.ccApiSeller.SELLERLIST) != null) {
        // The cast to List<Map<String, Object>> is necessary...
        List<Map<String, Object>> outputSellerList = (List<Map<String, Object>>) outputData.get(ccrz.ccApiSeller.SELLERLIST);
  
         // The cast, again, is necessary...
        String sellerName = (String) outputSellerList[0].get('sfdcName');
    }
} catch (Exception e) {
    // Error handling...
}