Saturday, April 3, 2021

Customize Sitecore Commerce Index Such as CustomersScope, OrdersScope

Sitecore Commerce search are mainly built for the purpose of searching in Business tool(Bizfx) with lesser fields but it can be easily extended to use this search index in storefront search.

I will explain using order search by adding OrderTotal field in sitecore commerce order scope index as it is not present so that we sort order based on order total amount.

All index fields are defined in "PlugIn.Search.PolicySet-1.0.0.json" file in folder path "..\wwwroot\data\Environments". We have to add new field inside order scope node inside this file and bootstraps through postman.

Below is the screen shot "PlugIn.Search.PolicySet-1.0.0.json" with order total field. 




 



All fields mention in policy set files are populated inside "InitializeOrdersIndexingViewBlock" block with in "IFullIndexMinionPipeline" pipeline. 

To populate new field we have to replace InitializeOrdersIndexingViewBlock with custom block inside "configuresitecore.cs" and then populate new fields along with old one in custom block "InitializeOrdersCustomIndexingViewBlock".




Then defined order total field in "managed-schema" file of order scope inside solr. Restart the solr and trigger "Run FullIndex Minion - Orders" api from postman or wait till incremental index kicks off(order scope incremental index runs in every 5 min interval).


Then use Search api from shop container to test new index field.

       
 Proxy.DoCommand(container.Search(ConfigSettings.EnbdOrderScopeName, term, status,
 	sortBy, take, skip));
       
 


No comments:

Post a Comment

Wishlist in Sitecore Commerce

In e-commerce, wishlist or saved products for later purchase is one of the important functionality. I have created simple plugin in sitecore...