Skip to content

Product Discovery Functions

The Product Discovery drop-in provides API functions that enable you to programmatically control behavior, fetch data, and integrate with Adobe Commerce backend services.

Version: 2.1.0
FunctionDescription
searchPerforms a product search based on the parameters.

The search function performs a product search based on the parameters. It updates the search context and emits events consumed by containers such as SearchResults, Facets, Pagination, and SortBy.

Passing null as the request parameter clears the current search state and resets related containers.

const search = async (
request: SearchVariables | null,
options: SearchOptions = {}
): Promise<ProductSearchResult>
ParameterTypeReq?Description
requestSearchVariables | nullYesSearch variables including `phrase` (search term), `pageSize` (results per page), `currentPage` (page number), `filter` (array of filter conditions), and `sort` (array of sort criteria). Pass `null` to clear the search state.
optionsSearchOptionsNoOptional search configuration options.

Events

Emits the search/loading, search/result, and search/error events during the search lifecycle to update containers with search state and results.

Returns

Returns ProductSearchResult.


Data Models

The following data models are used by functions in this drop-in.

ProductSearchResult

The ProductSearchResult object is returned by the following functions: search.

interface ProductSearchResult {
facets: SearchFacet[];
items: Product[];
pageInfo: {
currentPage: number;
totalPages: number;
totalItems: number;
pageSize: number;
};
suggestions?: string[];
totalCount: number;
metadata?: {
filterableAttributes: RefineOption[];
sortableAttributes: RefineOption[];
};
}