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 5 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

pcsdk.search(params).then(success).catch(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
typestringrequiredThe value should always be "instant_search".
search_querystringrequiredThe search query text.

API response

NameTypeDescription
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)
  • old_price – 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)
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)


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)
book_authorsarrayReserved.
collectionsarrayReserved.
keywordsarrayReserved.
virtual_categoriesarrayReserved.

Example of use

pcsdk.search({type: "instant_search", search_query: "To be or not to be"})
    .then((response) => {
        // features showing instant search widget
    })
    .catch((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.

Syntax and parameters

pcsdk.search(params).then(success).catch(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
typestringrequiredThe value should always be "full_search".
search_querystringrequiredThe search query text.
limitnumberoptionallyThe maximum number of products in the API response.
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)
sort_dirstringoptionally

Sorting directions for the sort_by parameter.
Available values:

  • asc - ascending sorting
  • desc - downwards sorting (by default)

API response

NameTypeDescription
htmlstringHTML code of the widget with full search results. Widget template is customizable in PersonaClick account.
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)
  • old_price – product old price (type: string, by 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)
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.
book_authorsarrayReserved.
categoriesarrayReserved.
collectionsarrayReserved.
keywordsarrayReserved.
queriesarrayReserved.
virtual_categoriesarrayReserved.

Example of use

pcsdk.search({
    type: "full_search", 
    search_query: "To be or not to be", 
    page: 2, 
    limit: 15, 
    brands: ["Alas", "poor", "Yorick"], 
    categories: [1, 146, 100500], 
    sort_by: "price", 
    sort_dir: "asc"
})
    .then((response) => {
        // features showing full search
    })
    .catch((error) => {
        // when something went wrong
    });
  • No labels