Search & querying

Aikey's search library is a great way of implementing fast personalised category views and search views.

 

searchTerm
[Not Required]
This is a free text search that accept any type of string. It can be used to implement a free text search function on your site. But without it you get a regular category type result.
orderBy
[Not Required] [Default: Title]
Order of the products returned. Can be set to:
orderByDirection
[Not Required] [Default: DESC]
Can be set to DESC for descending order or ASC for ascending.
limit
[Not Required] [Default: 6]
How many products should be returned.
offset
[Not Required] [Default: 0]
Offset where to start taking products from.
currency
[Not Required] [Default: first found]
What currency and price that should be returned. While this is not required it should always be provided when you use multiple currencies.
priceRange
[Not Required]
The Price Range can be used to filter down products in a certain price range. It is an object with from and to {from: 0, to: 200}.
facets
[Not Required]
Facets use the dynamic properties set to a product to filter down the results. This is sent in as a an object with property name as key and an array of property values as the objects value. {Category: [ "Sneakers", "Boots"]}
Aikey.products.search({
    searchTerm: "",
    orderBy: "title",
    orderByDirection: "DESC",
    limit: 6,
    offset: 0,
    currency: "EUR",
    priceRange: {from: 0, to: 200},
    properties: {
      Category: [ "Sneakers", "Boots" ],
      Color: ["White", "Blue"]
    }         
  }, function(response){
     //Callback with response
});

Response
{
  products: [
    {
      sku: "abc-123"
      title: "Example Product",
      price: {
        currency: "EUR", 
        value: 80
      },
      properties: [
        {
          name: "Color", 
          value: "White"
        },
        {
          name: "Gender", 
          value: "Men"
        }
      ],
      link: "https://example.io/men/sneakers/product/",
      imageLink: "https://example.io/media/product-image.jpg",
      description: "Lorem ipsum dolor sit amet."
    }
  ]
  itemCount: 5
  facets: {
    Color: [
      {
        label: "White", 
        count: 2, 
        selected: false
      }
  ],
  maxPrice: 85
}