Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

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

Code Block
languagejava
themeFadeToGrey
PersonaClick.search(search_query, type, params, callback);

NameTypeRequirementDescription
search_querystringrequiredThe search query text.
typeenumrequiredSearch Type. See the example below.
paramsenumrequiredRequest parameters. See the description below.
successfunctionrequiredCallback-function, where the API response will be passed to. 

Request parameters

NameTypeRequirementDescription
LOCATIONSstringoptionallyString with location IDs separated by comma. If used, the API response will return products available in the listed locations.

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)


Note

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

Code Block
languagejava
themeFadeToGrey
SearchParams params = new SearchParams();
params.put(SearchParams.Parameter.LOCATIONS, "NY,LA");
PersonaClick.search("To be or not to be", SearchParams.TYPE.INSTANT, params, new Api.OnApiCallbackListener() {
    @Override
    public void onSuccess(JSONObject response) {
        // 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.

Note

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

Code Block
themeFadeToGrey
personaclickPersonaClick.search("search"_query, paramstype, successparams, errorcallback);

NameTypeRequirementDescription
search_querystringrequiredThe search query text.
typeenumrequiredSearch Type. See the example below.
params
object
enumrequired
Object with request parameters
Request parameters. See the description below.
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_queryLIMITstringrequiredThe search query text.limitnumberoptionallyThe maximum number of products in the API response.
pagePAGEnumberstringoptionallyPage number (first page - 1, by default - 1).
offsetBRANDSnumberstringoptionallyThe 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 String with vendor names separated by comma. If used, the API response will return only the products of the listed vendors. The vendors must be listed in the product feed.
colorsCOLORSarraystringoptionallyAn array of product colors. If String with color names separated by comma. 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.
pricePRICE_minMINnumberstringoptionallyMinimum product price in API response.
pricePRICE_maxMAXnumberstringoptionallyMaximum product price in API response.
categoriesLOCATIONSarraystringoptionallyAn array of category IDsString with location IDs separated by comma. If used, the API response will return only those products that are available in the specified categorieslisted locations.
category_namesCATEGORIESnumberstringoptionallyUsing the category names in the search. If String with category IDs separated by comma. If used, the API response 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_byreturn only those products that are in the specified categories.
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)
orderSORT_DIRstringoptionally

Sorting directions for the sort_by parameter.
Available values:

  • asc - ascending sorting
  • desc - downwards sorting (by default)
FILTERSstringoptionallyAdditional request filters. See the example below.

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

Code Block
languagejs
themeFadeToGrey
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 wrongSearchParams params = new SearchParams();
params.put(SearchParams.Parameter.PAGE, "2");
params.put(SearchParams.Parameter.LIMIT, "15");
params.put(SearchParams.Parameter.BRANDS, "Alas,poor,Yorick");
params.put(SearchParams.Parameter.CATEGORIES, "1,146,100500");
params.put(SearchParams.Parameter.SORT_BY, "price");
params.put(SearchParams.Parameter.SORT_DIR, "asc");
params.put(SearchParams.Parameter.LOCATIONS, "NY,LA");
SearchParams.SearchFilters filters = new SearchParams.SearchFilters();
filters.put("weight", new String[] {"11.1", "14.8"});
params.put(SearchParams.Parameter.FILTERS, filters);
PersonaClick.search("To be or not to be", SearchParams.TYPE.FULL, params, new Api.OnApiCallbackListener() {
    @Override
    public void onSuccess(JSONObject response) {
        // features showing full search widget
    }
});


Table of Contents
maxLevel2
classpersonaclick-fixed-position