Home > widget-integration > InstantSearchController > processWidgetDataForRendering

InstantSearchController.processWidgetDataForRendering() method

Process suggestion data before passing it to the template renderer.

Extension point for TS teams to modify, filter, or augment suggestion data immediately before rendering — without overriding the entire render() method.

Signature:

protected processWidgetDataForRendering(data: SuggestionData): SuggestionData;

Parameters

Parameter

Type

Description

data

SuggestionData

Suggestion data about to be rendered

Returns:

SuggestionData

Data to pass to the template (identity by default)

Example

window.boostWidgetIntegration.extend('InstantSearchController', (InstantSearchController) => {
  return class CustomController extends InstantSearchController {
    protected processWidgetDataForRendering(data) {
      // Cap product count to 3 for this shop
      return { ...data, products: (data.products ?? []).slice(0, 3) };
    }
  };
});