TransWikia.com

How to do facet on Associate Categories of a Product in Sitecore Commerce 9.3

Sitecore Asked by Jinu on August 23, 2021

There is a Brand Facet for Products in sitecore commerce 9.3, likewise is it possible to have a facet on Categories associated with a Product.

By default categories are not indexed at product level in search provider (Solr). To do facet on a property that field needs to be indexed in the search providers.

So how to do facet on Category associated with a product.

One Answer

You have to create a custom index field and add custom logic to retrieve categories.

The code which you can use for it:

var allCategories = await this.Commander.Pipeline<IGetCategoriesPipeline>().Run(new GetCategoriesArgument(" "), context);           
var parentCategories = allCategories.Where(category =>
                    sellableItem.ParentCategoryList.Split('|').Any(id =>
                        id.Equals(category.SitecoreId, StringComparison.OrdinalIgnoreCase)));

Answered by Andrei Paliakou on August 23, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP