Sitecore Commerce catalog changes not appearing after minor edits
Our Sitecore Commerce catalog is fed by an import process where we typically import all of the data in a single import, which has worked OK up until now, but our client would like to be able to make small changes without having to go through the full import process. To facilitate this, we needed to ensure that minor edits (e.g. price change) from BizFX will appear on the website in a timely and well understood fashion. At first, we weren’t able to see the change reflected on the delivery server at all, so we started looking at clearing the Sitecore caches, but that still didn’t make the change appear without an app pool recycle, which is obviously not a good option when we get to a production environment. Knowing that the products refreshed OK when importing lots of them, we figured there had to be something going on under the hood that was preventing the change appearing.
Digging into the Sitecore Commerce code, I found this (from Sitecore.Commerce.Engine.Connect.dll, 9.0.2 version)
There’s the problem. After updating the index, it’s only going to drop the caches and reload the data if we’ve modified more than 20 items. (In later versions of Sitecore Commerce, this threshold is configurable via the configuration value FullCacheRefreshThreshold, so you could possibly set it to zero to solve this issue.)
To remediate the issue in this version, the simplest option within the existing structure is to add an additional handler after the existing one that will complete the product refresh and cache clear when less than 20 products have been changed.
Here’s the code to achieve that.
And here’s the Sitecore configuration file.
I hope this has been helpful. Thanks for reading. :-)