Versions Compared

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
languagejava
themeFadeToGrey
sdk.recommend(params) { callback }


NameTypeRequirementDescription
paramsenumrequiredRequest parameters.
callbackfunctionrequiredA callback function, to which the API response will be passed.

Request parameters

NameTypeRequirementDescription
blockIdstringrequiredUnique code of the recommendation block. See this value in the "data-recommender-code" attribute of the block created in PersonaClick account.
currentProductIdstringrequired in some casesProduct 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.
currentCategoryIdstringrequired in some casesThe parameter allows filtering products by a specified category, for example for the "Popular" algorithm in a category.

API response properties

NameTypeDescription
htmlstringHTML-code of the block with products. The template is customized in the PersonaClick account.
titlestringThe block title. Corresponds to the value of the "Action" element in the block rules.
recommendsObject Array

An array of objects with product information. Each object has the following properties:

  • barcode – product barcode, if it was imported in the product catalog (type: string)
  • brand – product vendor (type: string)
  • currency – product currency (type: string, matches the currency of the PersonaClick account, or the user value set in the settings of the PersonaClick account)
id – product ID
  • discount – the percentage difference between the old price and the current price (type:
string
  • integer)
isNew
  • id –
new arrival
  • product ID (type:
boolean). See the parameter in the product catalog import (XML, HTTP API
  • string)
  • imageUrl – URL of the original product image (type: string)
  • model –  model and product name (type: string)
  • name – product name (type: string)
  • oldPrice
 – old
  •  – integer old price of the product
with zeroed pennies  
  • (type: double)
  • oldPriceFormatted – formatted integer old price of the product, including currency (type: string)
  • oldPriceFull – old price of the product (type: double)
  • oldPriceFullFormatted – formatted old price of the product, including currency (type: string)
params –
  • paramsRaw – JSON of object array with pairs of "key" (type: string), "values" (type: array) properties. The data matches the values of the "param" parameter of the product feed/catalog (XML, HTTP API).
picture
  • resizedImageUrl – link to the product image in the PersonaClick image repository (type: string)
  • price
 –
  •  – integer current price of the product
with zeroed pennies
  • (type: double)
  • priceFormatted – formatted integer current price of the product, including currency (type: string)
  • priceFull – current price of the product (type: double)
  • priceFullFormatted – formatted current price of the product, including currency (type: string)
  • relativeSalesRate – level of sales of current product ( in percentage) in relation to the maximum level of sales of products in the store (type: float)
  • salesRate – level of product sales (absolute value) (type: integer)
  • url – product page URL (type: string)
idnumberUnique 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
languagejava
themeFadeToGrey
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
languagejava
themeFadeToGrey
sdk.recommend(blockId: "1fd1b3495137bc3c9299816026acf36f", currentProductId: "100500") { recommendResult in
  // the functionality of rendering a block of product recommendations
}

Filtering by category:

Code Block
languagejava
themeFadeToGrey
sdk.recommend(blockId: "1fd1b3495137bc3c9299816026acf36f", currentCategoryId: "146") { recommendResult in
  // the functionality of rendering a block of product recommendations
}



Column

Page Navigation

Table of Contents
maxLevel3
indent0px
stylenone




Related Pages

Filter by label (Content by label)
showLabelsfalse
showSpacefalse
sorttitle
cqllabel = "recommenders"