allBlogsList

Sitecore OrderCloud: Configure Search Facets

Introduction

August 01st, 2022

Search plays a key role for any eCommerce application. Some of the most common features are product search, filtering using facets, sorting, pagination, etc. Search Facets are one of the most useful features that help customers filter down the products based on product attributes, prize, size, color, etc., Sitecore OrderCloud comes with an amazing robust search interface out of the box. When it comes to configuring facets, it is the smoothest process I have seen in my recent experience working with other eCommerce platforms. In this blog post, I will show you how to configure facets for your product listing page.

Facets in Sitecore OrderCloud are always based on the property of a product that is defined in xp aka Extended Properties. Sitecore defines xp as: “A mechanism for adding properties to an object that my conceptual model needs but are not natively supported in OrderCloud.”

So, before we can configure facets, the first thing we need to define is a handful of extended properties which we would like to use as facets to help filter our search results.

I went ahead and created a couple of extended properties on my product called “Brand” and “Category”. As the names indicate, “Brand” holds the manufacturer/brand information for the product where as “Category” holds the product category. Here is an example of a product with that xp information.

Brand set to “Booster X Amplifiers” and Category set to “Amplifiers”

1

Once you have updated all or a selected list of products, we can get into enabling these as facets. To do so, navigate to Product Facets under the Product Catalogs section and select “Create a Product Facet”

To create a facet, we are expected to provide:

  • ID – Unique Identifier for your facet. If left empty, it gets auto-generated
  • Name – Required field
  • XpPath – This is the path of your facet property as an extended property. If you do not provide this value, it assumes the path to be product.xp.{facet.ID} by default
  • ListOrder – Defines the order in which this facet should display among other facets
  • MinCount – This allows us to configure the minimum results to be available before displaying the results. Default is 1. If you want facets with 0 results to be displayed as well, the value needs to be set to 0

We went ahead and created two facets with respective names. One for Brand and one for Category.

That’s all it takes. Now, when we make a call to the Sitecore OrderCloud Get products API, it will return all the facets by default along with the list of products.

The API request looks something like this, ~/products where the response provides us a list of all facets and their count.

2

We can now use this data to display search facets on our storefront as needed.

3

Upon selecting a facet to filter down your search further (Example: I am filtering down by category set to amplifiers). 

The API request looks something like this, ~/products?xp.Category=amplifiers where the response provides us a list of only the selected facet category and its count.

4

For more information on how to configure facets, refer to Sitecore OrderCloud documentation here.

References:

·        Sitecore OrderCloud Documentation

·        XCentium OrderCloud Forward