XRecommend Service

Prev Next

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

elementIds

string[]

The IDs of the elements

options

object

Options object that allows you to control the search result response

options.pathname

string

The pathname that includes the locale (default to 'default' locale)

context

object

Dynamic context object

queryId

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

elementId

string

The ID of the element

options

object

Options object that allows you to control the search result response

options.pathname

string

The pathname that includes the locale (default to 'default' locale)

context

object

Dynamic context object

queryId

string

An optional queryId passed to cancel a request

Returns

A Promise resolving to a Recommendations object:

{

  items: RecommendProduct[];

  ruleset: string;

  ruleEngine: string;

}