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 |
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.
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.
- 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
- 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. ccrz.ccApiProductIndex.BY_SEQUENCE Sort by the Sequence field on the product category record that the product index record references. ccrz.ccApiProductIndex.BY_START_DATE Sort by the value of the Start Date field on the product that the product index record references. - 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. - 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...
}