JavaScript SDK
Search
Response

Sending search requests

To use the SDK the awAddGift.js script has to be present and initialized. When the script is run the ADDWISH_PARTNER_NS variable is available on window. At this point you can call a method ADDWISH_PARTNER_NS.search.search(). That method takes three parameters:
Parameter #
Type
Description
#1
required
String
The key of the search config.
#2
required
String
The search word or phrase.
#3
optional
JSON
A JSON object with options that are sent with the search request. A little farther below you can see details about which options are available.

Options available

Field
Type
Description
format
String
A string value of either two options: "json" or "html".
filters
String[]
Limit product results to those matching the specified filter(s). By default, you can filter by price, inStock, hierarchies (categories), isOnSale, brand & created.
If you want to filter by other product attributes, then just contact support.
For more information about filters see documentation below.
sorting
String[]
Sort the order of the product result by specifying an array of sorting strings. The sorting strings are build up by the structure of "{field} {sort order}" where field can i.e. be "inStock" and sort order can be either "asc" for ascending or "desc" for descending order.
return_filters
boolean
If set to true it will return all filter value results that you requested in options.filters.
Default is: false
product_fields
String
(Only works if options.format is "json") A comma separated list of what fields you would like to have returned in the response.
Defaults is: all fields.
engine_options.product.start
integer
This is used for pagination, and is the offset.
Default is: 0
engine_options.product.current_count
integer
The number of product results you want to have returned. Default is: 10
engine_options.category.start
integer
This is used for pagination, and is the offset.
Default is: 0
engine_options.category.current_count
integer
The number of category results you want to have returned. Default is: 0
engine_options.site_page.start
integer
This is used for pagination, and is the offset.
Default is: 0
engine_options.site_page.current_count
integer
The number of site page results you want to have returned. Default is: 0
engine_options.blog_post.start
integer
This is used for pagination, and is the offset.
Default is: 0
engine_options.blog_post.current_count
integer
The number of blog post results you want to have returned. Default is: 0
engine_options.brand.start
integer
This is used for pagination, and is the offset.
Default is: 0
engine_options.brand.current_count
integer
The number of brand results you want to have returned. Default is: 0

Example

1
var options = {
2
callback: function(products) {
3
console.log(products);
4
},
5
format: "json",
6
return_filters: true,
7
filters:["hierarchies:shoes$female$running-shoesquot;],
8
sorting:["isOnSale asc", "price desc"],
9
engine_options: {
10
product: {
11
current_count: 10,
12
start: 0
13
},
14
category: {
15
current_count: 4,
16
start: 0
17
},
18
site_page: {
19
current_count: 2,
20
start: 0
21
},
22
blog_post: {
23
current_count: 1,
24
start: 0
25
},
26
brand: {
27
current_count: 2,
28
start: 0
29
}
30
}
31
};
32
33
ADDWISH_PARTNER_NS.search.search(
34
"1a41bcd8-bdff-4b4c-a6cf-59bc61d90371", // the search config key
35
"Red running shoes", // the search phrase
36
options
37
);
Copied!
1
{
2
"results": 33,
3
"start": 0,
4
"didTrackSearch": true,
5
"results": [
6
{
7
"title": "A specific shoe",
8
"imgUrl": "http://example.com/shoe/shoe_img.png",
9
"price": 100.0,
10
"currency": "DKK",
11
"url": "http://example.com/shoe/specificOne",
12
"priceFormatted": "100,00",
13
"description": "A shoe that is good for running",
14
"keywords": "shoes, running",
15
"inStock": true,
16
"extraData": {
17
"itemNumber": "0001"
18
},
19
"productNumber": "21"
20
},
21
...
22
...
23
],
24
categories: [
25
{
26
"title": "Running shoes",
27
"description": "Our collection of running shoes",
28
"url": "http://example.com/shoes/running/female",
29
"keywords": "shoes, running, female",
30
"hierarchy": [
31
"shoes",
32
"running",
33
"female"
34
]
35
],
36
brands: [
37
{
38
"title": "Rus",
39
"description": "Rus, professional shoes for running",
40
"url": "http://example.com/rus",
41
"keywords": "rus, shoes, running",
42
"hierarchy": [
43
"rus"
44
]
45
]
46
}
Copied!
You can read about filters here.
You can find the response values here.
Last modified 11mo ago
Copy link