ccrz.ccApiProductIndex.search

Executes a SOSL search of product index records and returns a list of records that match your search.

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

Service Layer Classes

Data Service Provider
ccrz.ccServiceProductIndex

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.ccApiProductIndex.ACTIVE
Boolean
Value Usage
true Return only product index records where the Active field is enabled.
false (default) Return product index records that match your other filter criteria, regardless of the Active field value.
ccrz.ccApiProductIndex.CURRENT_INDEX
Map<String, Object> that specifies a starting point for the method's query by indicating the last product index record within the previous set of sorted results. You can pass this map to subsequent ccrz.ccApiProductIndex.fetch, ccrz.ccApiProductIndex.search, or ccrz.ccApiProductIndex.fetchEntitled method calls for querying the next set of results. This map specifies the following subkeys:
Key Usage
primary The value that the ccrz.ccService.ORDERBY input key used for sorting product index records.
secondary The ID of the referenced product index record.

For example:

{
    "primary":"sort value, such as index price or product name",
    "secondary":"Product_Index_ID"
}
ccrz.ccApiProductIndex.LOCALE
String that specifies a locale to filter product index records by.
ccrz.ccApiProductIndex.STOREFRONT
String that specifies a storefront to filter product index records by.

Your version of B2B Commerce for Visualforce determines how the method filters by storefront:

Version Behavior
B2B Commerce for Visualforce Summer ’19 (managed package version 4.11 and API version 10) or later Queries the Storefront field directly on a product index record.
B2B Commerce for Visualforce Spring ’19 (managed package version 4.10 and API version 9) or earlier Queries the Storefront field on a product that a product index record references.

Note

ccrz.ccApiProductIndex.PRICE_LISTS
Set<String> of specific price list IDs whose associated product index records you want to search:
new Set<String>{'Price_List_ID_1', 'Price_List_ID_2'}
ccrz.ccApiProductIndex.PRODUCT_FILTERS
Map<String, Object> that specifies spec names and product IDs that have values defined for the specs. The method returns product index records that match the specified spec names and product IDs.
ccrz.ccApiProductIndex.PRODUCT_FILTERS => new Map<String, Object>{
    'color' => 'Product_ID_1','Product_ID_2'
    'width' => 'Product_ID_3','Product_ID_4'
}
ccrz.ccApiProductIndex.TYPE
String that specifies a value for the Index Type field to filter product index records by. By default, the only supported value is the key ccrz.ccApiProductIndex.INDEX_TYPE_SEARCH, which corresponds to the Index Type value U0VBUkNI, the Base64-encoded value for the string Search.
ccrz.ccApiProductIndex.TYPE => ccrz.ccApiProductIndex.INDEX_TYPE_SEARCH

B2B Commerce for Visualforce requires this format for identifying products assigned to multiple categories and ensuring that products appear only once in a search. When a product index record specifies U0VBUkNI for its Index Type, that product index is the record returned in search results.

Note

ccrz.ccService.ORDERBY
String that specifies a key, which indicates how you want to sort product index records. For example:
ccrz.ccService.ORDERBY => ccrz.ccApiProductIndex.BY_NAME
Value Usage
ccrz.ccApiProductIndex.BY_NAME Sort by the localized name of the product that the product index record references.
ccrz.ccApiProductIndex.BY_PRICE Sort by the Index Price field on the product index record.
ccrz.ccApiProductIndex.BY_RELEVANCE Sort by occurrences of the search string in the product's name, short description, and SKU.

Note

ccrz.ccApiProductIndex.BY_SEQUENCE Sort by the Sequence field on the product category record that the product index record references.
  • Sequence sorting is available only for product index records that match specified category IDs.
  • B2B Commerce for Visualforce Summer ’19 (managed package version 4.11, API version 10) or later flattens the data model required for referencing this Sequence value. The product index record includes a Product Category Sequence field, whose value is copied from the corresponding product category record's Sequence field.

Note

ccrz.ccApiProductIndex.BY_START_DATE Sort by the value of the Start Date field on the product that the product index record references.

B2B Commerce for Visualforce Summer ’19 (managed package version 4.11, API version 10) or later flattens the data model required for referencing this Start Date value. The product index record includes a Product Start Date field, whose value is copied from the corresponding product record's Start Date field.

Note

ccrz.ccService.SEARCHSTRING
String to search for among product index records. The method adds a trailing wildcard to the string.

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.ccApiProductIndex.PRODUCT_INDICES
List<Map<String, Object>>, where each Map<String, Object> represents a product index record.

Example

Search product index records for the string espresso. Order the returned product index records by the Indexed Price field.

Map<String, Object> searchInputData = new Map<String, Object>{
    ccrz.ccApi.API_VERSION => ccrz.ccApi.CURRENT_VERSION,
    ccrz.ccService.SEARCHSTRING => 'espresso',
    ccrz.ccApiProductIndex.TYPE => ccrz.ccApiProductIndex.INDEX_TYPE_SEARCH,
    ccrz.ccService.ORDERBY => ccrz.ccApiProductIndex.BY_PRICE
};
 
try { 
    Map<String, Object> searchReturnData = ccrz.ccApiProductIndex.search(searchInputData);    
} catch (Exception e) {
    // Error handling...
}