Overview
To modify a search response, the incoming response object is intercepted and any of the available datapoints can be manipulated as needed prior to being sent to the UI templates.
There are two steps:
- Intercept the incoming response object
- Identify the data object to be modified
Any of the product attributes are available to be modified as needed or otherwise inject any custom values.
Use the klevu.modifyResponse function to intercept the response data.
The simplest way to get acquainted with the available data is to use console.log and review the output.
For example, the following snippet loops through each record in the productList result and outputs the product object to the browser's developer console.log
Note that each klevu.modifyResponse function requires definition within the corresponding scope of the override. We will chart these below.
Scope | Description |
---|---|
all | Applies to all scope modules |
quick | QuickSearch module |
landing | SRLP module |
catnav | Category module |
full_page | Both SRLP and Category modules (same as "landing,catnav") |
Multiple klevu.modifyResponse functions can be applied in the same or mixed scope.
Please see the Modify Response Examples section for details of common uses.
.