Home > widget-integration > InstantSearchAPI > enrichWidgetResponse
InstantSearchAPI.enrichWidgetResponse() method
Enrich a suggestion response with shop-specific data.
Called by handleWidgetResponse(). Override this method to re-rank products, inject promotions, append custom metadata, or pin specific results.
Signature:
protected enrichWidgetResponse(response: SuggestionResponse): SuggestionResponse;
Parameters
|
Parameter |
Type |
Description |
|---|---|---|
|
response |
Suggestion response to enrich |
Returns:
Enriched suggestion response (identity by default)
Example
window.boostWidgetIntegration.extend('InstantSearchAPI', (InstantSearchAPI) => {
return class CustomAPI extends InstantSearchAPI {
protected enrichWidgetResponse(response) {
// Inject a sponsored product at position 0
return {
...response,
products: [sponsoredProduct, ...(response.products ?? [])],
};
}
};
});