Skip to content

Search is only available in production builds. Try building and previewing the site to test it out locally.

Product Discovery Data & Events

The Product Discovery drop-in uses the event bus to emit and listen to events for communication between drop-ins and external integrations.

Version: 2.1.0

Events reference

EventDirectionDescription
search/errorEmits and listensTriggered when an error occurs.
search/loadingEmits and listensTriggered when loading state changes.
search/resultEmits and listensTriggered when results are available.

Event details

The following sections provide detailed information about each event, including its direction, event payload, and usage examples.

search/error (emits and listens)

Emitted when an error occurs during search operations such as query execution or facet loading.

Event payload

string

Example

import { events } from '@dropins/tools/event-bus.js';
events.on('search/error', (payload) => {
console.log('search/error event received:', payload);
// Add your custom logic here
});

search/loading (emits and listens)

Triggered when loading state changes.

Event payload

boolean

Example

import { events } from '@dropins/tools/event-bus.js';
events.on('search/loading', (payload) => {
console.log('search/loading event received:', payload);
// Add your custom logic here
});

search/result (emits and listens)

Triggered when results are available.

Event payload

{
result: ProductSearchResult;
request: SearchVariables;
}

See ProductSearchResult, SearchVariables for full type definitions.

Example

import { events } from '@dropins/tools/event-bus.js';
events.on('search/result', (payload) => {
console.log('search/result event received:', payload);
// Add your custom logic here
});

Data Models

The following data models are used in event payloads for this drop-in.

ProductSearchResult

Used in: search/result.

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

SearchVariables

Used in: search/result.

interface SearchVariables {
scope?: Scope;
phrase?: string;
filter?: SearchFilter[];
sort?: SortOrder[];
currentPage?: number;
pageSize?: number;
context?: SearchContext;
}