Product to products

Returns the products that are related to an anchor product (often the product the user is currently engaging with) and are also likely to drive conversions by connecting with the user’s interests.


Syntax

const response = await client.api.recommendation.productToProducts(payload, options);

Payload

The payload parameter is an object with the following properties:

Name Type Description
engine_id string The engine you want to get results from. If not specified, the default engine will be used.
product_id string The product_id of the anchor product to recommend against.
product_ids array of strings An array of product_id of the anchor products to recommend against.
product_group_id string The product_group_id of the anchor product to recommend against.
buy_together boolean Whether to focus on the Products that are frequently bought together. Default: false.
fq string A query string in Solr syntax which restricts the superset of products to return, without influencing the overall ranking.
fl array of strings List of fields to retrieve. The field product_id is always included. When not specified, only product_id will be retrieved. You can retrieve all fields with ["*"]. Default: ["*"].
type string Specify the type of product to return.
pagination_id string A unique identifier to enable pagination in Recommendation APIs. To enable pagination, you generate a pagination_id and set it in the first and subsequent requests in the same browsing session where you want to enable pagination.
start integer The offset of records to retrieve. You can only set it when pagination_id is specified. Default: 0.
rows integer Number of records to retrieve. Default: 5.

Options

The options parameter is an optional object with the following properties:

Name Type Description
timeout integer Request timeout in milliseconds.
bulk boolean Bulked API requests froms the same event loop is packed into a single HTTP request. Default: false.

See the request options page for more details.

Return value

A Promise of response object with the following properties:

Name Type Description
products array of objects An array of Product records. Use fl parameter to specify what fields are returned.

Examples

const payload = {
product_id: '...',
buy_together: true,
fl: ['title', 'sale_price', 'custom_attributes.*']
};
const { products } = await client.api.recommendation.productToProducts(payload);

Learn more