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 23 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.

Note that to integrate the "Instant Search" tool it is enough to add the "personaclick-instant-search" class to the "input" tag used to enter the search query. Using this class as a selector, the PersonaClick library will show the widget by itself. The method described below should be used only if you need to show the instant search widget following your logic.

Syntax and parameters

personaclick("suggest", params, success, error);

NameTypeRequirementDescription
paramsobjectrequiredObject with request parameters.
successfunctionrequiredCallback-function, where the API response will be passed to. Response type: object.
errorfunctionoptionallyCallback-function to be called when an error occurs (any HTTP status code other than 200).

Request parameters

NameTypeRequirementDescription
search_querystringrequiredThe search query text.

API response

Name
Type
Description
productsarrayAn array of objects with product information. Each object has the following properties:
  • id – product ID (type: string)
  • name – product name (type: string)
  • url – product page link (type: string)
  • picture – link to the product image in the PersonaClick image repository (type: string)
  • price – product price (type: number)
  • oldprice – product old price (type: string, default – 0)
  • currency – product currency (type: string, matches the currency of the PersonaClick account, or the user value set in the settings of the PersonaClick account)
  • price_formatted – formatted product price including currency (type: string)
  • brand – product vendor (type: string)
  • is_new – new arrival product (type: boolean). See the parameter in the product catalog import (XML, HTTP API)
products_totalnumberThe total number of products that match the search query.
search_querystringThe search query text.
categoriesarray

An array of objects with information about the categories matching the search query. Each object has the following properties:

  • id – category ID (type: string)
  • name – category name (type: string)
  • url – category page link (type: string)
  • parent – parent category ID (type: string)
  • alias – wordy category identifier (type: string)

If no links are specified for categories in the product feed, the API will return an empty array for this property.

queriesarrayAn array of objects with relevant popular queries. Each object has the following properties:
  • name – relevant search query (type: string)
  • url – link to a full search page (the format of the link is configured in the PersonaClick account)
htmlstringContains a rendered custom HTML template for the Instant Search widget, or null if the HTML template is empty or the default one is used.
search_query_redirectsobject

The object will be available if a redirect is created for the search query: Account -> Search -> Search redirect

The object contains the following properties:

  • deep_link (type: string)
  • query (type: string)
  • redirect_link (type: string)

Example of use

personaclick("suggest", {search_query: "To be or not to be"}, function(response) {
  // features showing instant search widget
}, function(error) {
  // when something went wrong
});



Full Search

Method Objective

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

Note that the Full Search tool can be integrated by placing a configured DIV on the search page. The DIV will be filled with products matching the search query automatically. You can find the DIV in the Search Section of the PersonaClick account.

Syntax and parameters

personaclick("search", params, success, error);

NameTypeRequirementDescription
paramsobjectrequiredObject with request parameters.
successfunctionrequiredCallback-function, where the API response will be passed to. Response type: object.
errorfunctionoptionallyCallback-function to be called when an error occurs (any HTTP status code other than 200).

Request Parameters

NameTypeRequirementDescription
search_querystringrequiredThe search query text.
limitnumberoptionallyThe maximum number of products in the API response (by default - 10).
pagenumberoptionallyPage number (first page - 1, by default - 1).
offsetnumberoptionallyThe offset relative to the first product in the API response (similar to: (page - 1) * limit and when used simultaneously with page is a priority, by default - 0).
brandsarrayoptionallyAn array of vendor names. If used, the API response will return only the products of the listed vendors. The vendors must be listed in the product feed.
colorsarrayoptionallyAn array of product 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.
price_minnumberoptionallyMinimum product price in API response.
price_maxnumberoptionallyMaximum product price in API response.
categoriesarrayoptionallyAn array of category IDs. If used, the API response will return only those products that are in the specified categories.
category_namesnumberoptionallyUsing the category names in the search. If used, the API will respond with products from categories whose names intersect with the search query. These products will get the lowest priority and will be at the very end of the response. By default - 1.
sort_bystringoptionallySorting 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)
orderstringoptionally

Sorting directions for the sort_by parameter.
Available values:

  • asc - ascending sorting
  • desc - downwards sorting (by default)
category_limitnumberoptionallyThe maximum number of categories in the API response matching the search query.
extendednumberoptionally

If the value is 1, the API will return additional product properties in the response: barcode, categories, param. See the descriptions below.

locationsstringoptionallyComma-separated location IDs. If used, the API will return only products available in the specified locations. Locations must be specified in the imported product catalog (XML, HTTP API).
filtersstringoptionally

JSON string with the properties and their values that the products should match in the API response. The data matches the values of the "param" parameter of the product feed/catalog (XML, HTTP API). Format:

{"property1":["value1","value2"],"property2":["value1","value2"]}
excludestringoptionallyComma-separated products IDs to exclude from search results.

API response

NameTypeDescription
htmlstringHTML code of the widget with full search results. Widget template is customizable in PersonaClick account.
productsarray

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)
  • categories – an Object array with details of the product category hierarchy, where each object has properties:
    "id" – category ID (type: string)
    "level" – сategory level in the hierarchy (type: string)
    "name" – category name (type: string)
    "name_with_parent" – string name from the name of the parent and main product categories, separated by a "-" (type: string)
    "parent_id" – parent category ID (type: string)
    "url" – category page url (type: string)
  • category_ids – an array of IDs of the product category hierarchy (type: String array)
  • currency – product currency (type: string, matches the currency of the PersonaClick account, or the user value set in the settings of the PersonaClick account)
  • discount – the percentage difference between the old price and the current price (type: number)
  • discount_formatted – the percentage difference between the old and the current price that is formatted as a string with the "%" symbol (type: string)
  • id – product ID (type: string)
  • image_url – URL of the original product image (type: string)
  • image_url_handle – relative URL of the original product image (type: string)
  • image_url_resized – the object with the URLs of the resize product image. Available object keys matching the size of the image in pixels: 120, 140, 160, 180, 200, 220, 310, 520 (type: object)
  • is_new – new arrival product (type: boolean). See the parameter in the product catalog import (XML, HTTP API)
  • leftovers – rough number of the products left in stock. Available values are: 
    "one" - one product
    "few" - 2-10 products
    "lot" - over 10 products
  • model –  model and product name (type: string)
  • name – product name (type: string)
  • oldprice – integer old price of the product (type: number)
  • oldprice_formatted – formatted integer old price of the product, including currency (type: string)
  • oldprice_full – old price of the product (type: number)
  • oldprice_full_formatted – formatted old price of the product, including currency (type: string)
  • params – 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 – integer current price of the product (type: number)
  • price_formatted – formatted integer current price of the product, including currency (type: string)
  • price_full – current price of the product (type: number)
  • price_full_formatted – formatted current price of the product, including currency (type: string)
  • rating – product rating (type: number)
  • relative_sales_rate – level of sales of current product ( in percentage) in relation to the maximum level of sales of products in the store (type: number)
  • sales_rate – level of product sales (absolute value) (type: number)
  • url – product page URL (type: string)
  • url_handle - relative product page URL (type: string)
products_totalnumberThe total number of products that match the search query. The following query parameters do not affect this value: page, limit, and offset.
search_querystringThe search query text.
brandsObject arrayObject array, each containing the name property with the vendor name in the value.
categoriesObject array

An array of objects with information about the categories matching the search query. Each object has the following properties:

  • id – category ID (type: string)
  • name – category name (type: string)
  • url – category page link (type: string)
  • parent – parent category ID (type: string)
  • alias – wordy category identifier (type: string)

If no links are specified for categories in the product feed, the API will return an empty array for this property.

filtersObject

JSON string with properties and their values of all API response products. The data matches the values of the "param" parameter of the product feed/catalog (XML, HTTP API). Format:

{"property1":["value1","value2"],"property2":["value1","value2"]}
popupObjectReserved for the JS SDK internal use
price_rangeObject

The object containing the values of the minimum and maximum price of the products in the API response. Available properties:

  • min - minimum price
  • max - maximum price
queriesarrayReserved.

Example of use

personaclick("search", {search_query: "To be or not to be", page: 2, limit: 15, brands: ["Alas", "poor", "Yorick"], categories: [1, 146, 100500], sort_by: "price", order: "asc"}, function(response) {
  // features showing full search widget
}, function(error) {
  // when something went wrong
});
  • No labels