Change response filters used by out-of-the-box widgets
If you want to change the response filter used in one of the default widgets (described in Out-of-the-box response filters), Oracle recommends that you create a new response filter and assign it to the endpoint/identifier combination the widget uses in its context object.
To do this, you create an application-level JavaScript module that requires in the CCStoreConfiguration
library and creates a modified version of the filter map. As a reminder, the default filter map looks like this:
define(
//-------------------------------------------------------------------
// DEPENDENCIES
//-------------------------------------------------------------------
['ccStoreConfiguration'],
//-------------------------------------------------------------------
// Module definition
//-------------------------------------------------------------------
function(CCStoreConfiguration) {
'use strict';
return {
onLoad : function() {
console.log("Loading Application Level JS");
var filterMap = {
"getCollection":{
"megaMenuNavigation": {"ccFilterConfigKey": "categoryNavData"},
"categoryNavigation": {"ccFilterConfigKey": "categoryNavData"}
},
"listProducts":{
"productListingData": {"ccFilterConfigKey": "PLPData"},
"collectionWidget": {"ccFilterConfigKey": "collectionData"},
"getProductData": {"ccFilterConfigKey": "productData"},
"getProductDataAndRedirect": {"ccFilterConfigKey": "productData"},
}
};
CCStoreConfiguration.getInstance().updateFiltersToUse(newFilterMap);
},
}
}
);
The code in this example changes the response filter key for the Collection Navigation
widget from categoryNavData
to customFilterKey1
.
define(
//-------------------------------------------------------------------
// DEPENDENCIES
//-------------------------------------------------------------------
['ccStoreConfiguration'],
//-------------------------------------------------------------------
// Module definition
//-------------------------------------------------------------------
function(CCStoreConfiguration) {
'use strict';
return {
onLoad : function() {
console.log("Loading Application Level JS");
var filterMap = {
"getCollection":{
"megaMenuNavigation": {"ccFilterConfigKey": "customFilterKey1"},
"categoryNavigation": {"ccFilterConfigKey": "categoryNavData"}
},
"listProducts":{
"productListingData": {"ccFilterConfigKey": "PLPData"},
"collectionWidget": {"ccFilterConfigKey": "collectionData"},
"getProductData": {"ccFilterConfigKey": "productData"},
"getProductDataAndRedirect": {"ccFilterConfigKey": "productData"},
}
};
CCStoreConfiguration.getInstance().updateFiltersToUse(newFilterMap);
},
}
}
);
Remember that the top-level objects you define in the filter map override any default top-level objects. In other words, if you modify a top-level object in the filter map, only the identifiers you explicitly include your top-level object are used by the CCStoreConfiguration
library. For this reason, you should be careful to include the default identifiers in top-level objects to avoid overwriting them. See Add a new response filter key to the out-of the-box filter map for more information.
The following table defines which identifier and filter key combination is used by the default widgets:
Widget | Endpoint | Identifier | Response filter Key |
---|---|---|---|
Collection Navigation | getCollection | megaMenuNavigation | categoryNavData |
Collection Navigation – Basic | getCollection | categoryNavigation | categoryNavData |
Product Listing | listProducts | productListingData | PLPData |
Collection | listProducts | collectionWidget | collectionData |