The Search controller lets you create a commerce search page.

Example: search.fn.tsx

interface Search {
    state: SearchState;
    breadcrumbManager(): BreadcrumbManager;
    didYouMean(): DidYouMean;
    executeFirstSearch(): void;
    facetGenerator(): FacetGenerator;
    interactiveProduct(props: InteractiveProductProps): InteractiveProduct;
    pagination(props?: PaginationProps): Pagination;
    parameterManager(
        props?: ParameterManagerProps<CommerceSearchParameters>,
    ): ParameterManager<CommerceSearchParameters>;
    promoteChildToParent(child: ChildProduct): void;
    sort(props?: SortProps): Sort;
    subscribe(listener: () => void): Unsubscribe;
    summary(): Summary<SearchSummaryState>;
    urlManager(props: UrlManagerProps): UrlManager;
}

Hierarchy (View Summary)

Methods

  • Creates a BreadcrumbManager sub-controller.

    Returns BreadcrumbManager

    A BreadcrumbManager sub-controller.

  • Creates a DidYouMean sub-controller.

    Returns DidYouMean

    A DidYouMean sub-controller.

  • Executes the first search.

    Returns void

  • Creates a FacetGenerator sub-controller.

    Returns FacetGenerator

    A FacetGenerator sub-controller.

  • Creates an InteractiveProduct sub-controller.

    Parameters

    Returns InteractiveProduct

    An InteractiveProduct sub-controller.

  • Creates a Pagination sub-controller.

    Parameters

    • Optionalprops: PaginationProps

      The optional properties for the Pagination sub-controller.

    Returns Pagination

    A Pagination sub-controller.

  • Finds the specified parent product and the specified child product of that parent, and makes that child the new parent. The children and totalNumberOfChildren properties of the original parent are preserved in the new parent.

    This method is useful when leveraging the product grouping feature to allow users to select nested products.

    E.g., if a product has children (such as color variations), you can call this method when the user selects a child to make that child the new parent product, and re-render the product as such in the storefront.

    Note: In the controller state, a product that has children will always include itself as its own child so that it can be rendered as a nested product, and restored as the parent product through this method as needed.

    Parameters

    • child: ChildProduct

      The child product that will become the new parent.

    Returns void

  • Creates a Sort sub-controller.

    Parameters

    • Optionalprops: SortProps

      Optional properties for the Sort sub-controller.

    Returns Sort

    A Sort sub-controller.

  • Adds a callback that's invoked on state change.

    Parameters

    • listener: () => void

      A callback that's invoked on state change.

    Returns Unsubscribe

    A function to remove the listener.

  • Creates a Summary sub-controller.

    Returns Summary<SearchSummaryState>

    A Summary sub-controller.

  • Creates a UrlManager sub-controller with the specified properties.

    Parameters

    • props: UrlManagerProps

      Properties for the UrlManager sub-controller.

    Returns UrlManager

    A UrlManager sub-controller.

Properties

state: SearchState

A scoped and simplified part of the headless state that is relevant to the Search controller.