Home > widget-integration > FilterController > fetchInCollectionSearch

FilterController.fetchInCollectionSearch() method

Fetches and updates products based on in-collection search input. Triggers search when user types in the collection search box.

This method: - Resets pagination to page 1 - Updates URL parameters with search query - Disables input during fetch to prevent concurrent requests - Fetches filtered results from the API - Dispatches analytics event for search - Re-enables input after completion

Signature:

protected fetchInCollectionSearch(urlParams: URLSearchParams, inputElement: HTMLInputElement): Promise<void>;

Parameters

Parameter

Type

Description

urlParams

URLSearchParams

URL search parameters to update with search query

inputElement

HTMLInputElement

The search input element to disable/enable

Returns:

Promise<void>

Remarks

This method is called by handleInCollectionSearch after debouncing user input. The input is temporarily disabled to provide visual feedback and prevent race conditions from rapid typing.

Example

Override to add custom search behavior:

window.boostWidgetIntegration.extend('FilterController', (FilterController) => {
  return class CustomFilterController extends FilterController {
    async fetchInCollectionSearch(urlParams, inputElement) {
      // Add loading indicator
      inputElement.classList.add('searching');

      // Track search in analytics
      this.trackSearchQuery(urlParams.get('q'));

      await super.fetchInCollectionSearch(urlParams, inputElement);

      inputElement.classList.remove('searching');
    }
  };
});