3

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.

2
  • You can create a custom computed field which indexes in Product level, which takes the values associated with the category. So once the computed field is indexed, we will be able to use it in search, Product Listing page or any custom logic. – Sreekrishnan Jul 20 '20 at 8:37
  • I have tried that but computed index is not triggering while rebuilding the index. In Sitecore commerce 9.3 the commerce items rebuilding strategy has been changed.There is an option to create a custom index field handler [link]( doc.sitecore.com/developers/93/sitecore-experience-commerce/en/…). Above requirement can be achieved through custom index field handler, need to right a logic to get the categories associated with the product, but the issue is in this handler we cannot resolve instance of a pipeline or command. – Jinu Jul 20 '20 at 15:41
1

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)));

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.