Methods
// Returns a recommendation response mapped by element IDs.
xg.recommend.getResults({ elementIds: ['<element_id_1>', '<element_id_2>'], { pathname: '/en-us/' } });
// Returns a recommendation response for the given element ID.
xg.recommend.getResultsById({ elementId: '<element_id>', { pathname: '/en-us/' } });
getResults
getResults
Description: Gets recommendation results by a list of elementIds.
Parameters
Name | Type | Required | Description |
| string[] | ✅ | The IDs of the elements |
| object | ✅ | Options object that allows you to control the search result response |
↳ | string | ❌ | The pathname that includes the locale (default to 'default' locale) |
| object | ❌ | Dynamic context object |
| string | ❌ | An optional queryId passed to cancel a request |
Returns
A Promise
resolving to a Recommendations
object:
{
[key: string]: {
items: RecommendProduct[];
ruleEngine: string;
ruleset: string;
};
}
getResultsById
getResultsById
Description: Gets recommendation results by a single elementId.
Parameters
Name | Type | Required | Description |
| string | ✅ | The ID of the element |
| object | ✅ | Options object that allows you to control the search result response |
↳ | string | ❌ | The pathname that includes the locale (default to 'default' locale) |
| object | ❌ | Dynamic context object |
| string | ❌ | An optional queryId passed to cancel a request |
Returns
A Promise
resolving to a Recommendations
object:
{
items: RecommendProduct[];
ruleset: string;
ruleEngine: string;
}