Versions Compared
compared with
Key
- This line was added.
- This line was removed.
- Formatting was changed.
Method Objective
The method returns an API response when requesting product recommendations.
Syntax and parameters
Code Block | ||||
---|---|---|---|---|
| ||||
sdk.recommend(params) { callback } |
Name | Type | Requirement | Description |
---|---|---|---|
params | enum | required | Request parameters. |
callback | function | required | A callback function, to which the API response will be passed. |
Request parameters
Name | Type | Requirement | Description |
---|---|---|---|
blockId | string | required | Unique code of the recommendation block. See this value in the "data-recommender-code" attribute of the block created in PersonaClick account. |
currentProductId | string | required in some cases | Product ID. This parameter is mandatory for the requests of blocks with algorithms that depend on the current product. Algorithms: "Similar", "Products usually purchased with this product", "Store recommendations", etc. |
currentCategoryId | string | required in some cases | The parameter allows filtering products by a specified category, for example for the "Popular" algorithm in a category. |
API response properties
Name | Type | Description |
---|---|---|
html | string | HTML-code of the block with products. The template is customized in the PersonaClick account. |
title | string | The block title. Corresponds to the value of the "Action" element in the block rules. |
recommends | array/Object ArrayArray | An array of objects with product IDs. If an extended response is requested, this property will have an object array with extended information for each product.information. Each object has the following properties:
|
id | number | Unique block identifier. Corresponds to the block ID in the list of blocks in the PersonaClick account. |
Examples of use
For blocks with algorithms without any additional parameters:
Code Block | ||||
---|---|---|---|---|
| ||||
sdk.recommend(blockId: "1fd1b3495137bc3c9299816026acf36f") { recommendResult in // the functionality of rendering a block of product recommendations } |
For blocks with algorithms that require the "Product ID":
Code Block | ||||
---|---|---|---|---|
| ||||
sdk.recommend(blockId: "1fd1b3495137bc3c9299816026acf36f", currentProductId: "100500") { recommendResult in
// the functionality of rendering a block of product recommendations
} |
Filtering by category:
Code Block | ||||
---|---|---|---|---|
| ||||
sdk.recommend(blockId: "1fd1b3495137bc3c9299816026acf36f", currentCategoryId: "146") { recommendResult in
// the functionality of rendering a block of product recommendations
} |
Column | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Page Navigation
Related Pages
|