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.
| Function | Description |
|---|---|
search | Performs a product search based on the parameters. |
search
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>| Parameter | Type | Req? | Description |
|---|---|---|---|
request | SearchVariables | null | Yes | Search 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. |
options | SearchOptions | No | Optional 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[]; };}