Home > widget-integration > RecommendationService > getWidgetProductIds
RecommendationService.getWidgetProductIds() method
Retrieves product IDs for a specific widget based on recommendation type and page context.
This method orchestrates calls to specific product ID retrieval methods based on the recommendation type and current page. Can be overridden for complex custom logic that doesn't fit the default flow.
Signature:
getWidgetProductIds(widgetId: string): Promise<(string | number)[]>;
Parameters
|
Parameter |
Type |
Description |
|---|---|---|
|
widgetId |
string |
The widget identifier used to determine recommendation type and configuration |
Returns:
Promise<(string | number)[]>
Promise resolving to array of product IDs (string or number) to use for recommendations. Returns empty array if the recommendation type doesn't require product IDs or if none are available.
Example
Override to add complementary products:
async getWidgetProductIds(widgetId: string): Promise<(string | number)[]> {
const productIds = await super.getWidgetProductIds(widgetId);
// Add complementary products for this shop
const complementary = await this.getComplementaryProducts(productIds);
return [...productIds, ...complementary];
}