Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 11 Next »

Instant Search

Method Objective

The method requests products that match the search query. The method must be called for each entered character of the search query. The search for products starts from the second entered symbol.

Syntax and parameters

sdk.suggest(params) { callback }

NameTypeRequirementDescription
params
requiredRequest parameters. See the description below.
callbackfunctionrequiredCallback-function, where the API response will be passed to. 

Request parameters

NameTypeRequirementDescription
querystringrequiredThe search query text.

API response

NameTypeDescription
categoriesarrayHTML code of the widget with full search results. Widget template is customizable in PersonaClick account.
productsarrayAn array with data of products.
productsTotalnumberThe total number of products that match the search query.
queriesarrayAn array of queries related to the search query.

Example of use

sdk.suggest(query: "To be or not to be") { searchResult in
    // features showing instant search widget
}



Full Search

Method Objective

The method requests products that match the full search query and is used to display the search results.

Syntax and parameters

sdk.search(params) { callback }

NameTypeRequirementDescription
paramsenumrequiredRequest parameters. See the description below.
callbackfunctionrequiredCallback-function, where the API response will be passed to. 

Request Parameters

NameTypeRequirementDescription
querystringrequiredThe search query text.
limitnumberoptionallyThe maximum number of products in the API response.
offsetnumberoptionallyThe offset relative to the first product in the API response
brandsDictionary ListoptionallyDictionary List of brands. If used, the API response will return only the products of the listed vendors. The vendors must be listed in the product feed.
colorsDictionary ListoptionallyDictionary List of colors. If used, the API response will return the products of the listed colors. The colors of the product should be specified in the product feed.
priceMinnumberoptionallyMinimum product price in API response.
priceMaxnumberoptionallyMaximum product price in API response.
locationsDictionary ListoptionallyDictionary List of Location IDs. If used, the API response will return products available in the listed locations.
categoriesDictionary ListoptionallyDictionary List of Category IDs. If used, the API response will return only those products that are in the specified categories.
sortBystringoptionallySorting products in the API response.
Available values:
  • popular - sorting products by popularity (by default
  • price - sorting by product price
  • discount - sorting by discount (the difference between oldprice and price in the product feed)
sortDirstringoptionally

Sorting directions for the sort_by parameter.
Available values:

  • asc - ascending sorting
  • desc - downwards sorting (by default)
filtersstringoptionallyJSON object with additional request filters. See the example below.
categoryLimitnumberoptionallyHow many categories for sidebar filter to return.
excludeDictionary ListoptionallyDictionary List of IDs of products to be excluded.

API response

NameTypeDescription
categoriesarrayHTML code of the widget with full search results. Widget template is customizable in PersonaClick account.
productsObject 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 (type: string)
  • isNew – new arrival product (type: boolean). See the parameter in the product catalog import (XML, HTTP API)
  • model –  model and product name (type: string)
  • name – product name (type: string)
  • oldPrice – 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 – 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 – link to the product image in the PersonaClick image repository (type: string)
  • price – 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)
  • url – product page URL (type: string)
productsTotalnumberThe total number of products that match the search query.
queriesarrayAn array of queries related to the search query.

Example of use

sdk.search(query: "To be or not to be", limit: 15, offset: 3, categoryLimit: 5, categories: ["1", "146", "100500"], extended: false, sortBy: "price", sortDir: "asc", locations: ["NY", "LA"], brands: ["Alas", "poor", "Yorick"], filters: ["bluetooth":["yes"],"offers":["15% cashback"],"weight":["1.6"]], priceMin: 1000, priceMax: 5000, colors: ["red", "yellow", "green"], exclude: ["100", "146", "231"]) { searchResult in
    // features showing full search widget
}
  • No labels