We’ve got a situation once where Sitecore Commerce catalog data got corrupted in Sitecore, which led to all kinds of issues due to Sitecore being unable to read or index Commerce items. No meaningful information in Sitecore and Commerce Engine logs, no clues whatsoever, Sitecore would just freeze when trying to read catalog data. IIS reset would unfreeze it, but only until it tries to read catalog data again… Took a while to figure this one out, but here is the solution that worked for us.
Turned out the root cause had something to do with auto-generated commerce templates. We use Unicorn to source-control and deploy Sitecore items across different environments. Somebody included auto-generated Commerce templates into the source repository, they got deployed to all environments and things went well until we changed some of the Commerce fields in Commerce code. Next deployment pushed new code with old templates, so Sitecore couldn’t read catalog data properly anymore.
Eventually, we figured where the real issue was, re-generated Commerce templates, but then it took few extra steps to get Sitecore and Commerce back to normal.
Here are the resolution steps that worked
Backup Commerce “shared” database as well as Sicore master and web databases (or, in Azure, check if SQL Azure is backed up automatically)
Navigate Sitecore DB Browser ([your instance]/sitecore/admin/dbbrowser.aspx)
- Switch to web database
- Select immediate parent of problem “Catalogs” item. In my case this was at /sitecore/Commerce/Catalog Management/Catalogs, but starting with SXC 9.0.2 catalogs can be configured to show up anywhere in content tree, for example default SXA storefront has catalog root at /sitecore/content/Sitecore/Storefront/Home/Product catalog
- Click on “Delete Children” and give it few minutes to finish
- Navigate to /sitecore/templates/Commerce/Catalog Generated
- Click “Delete”, let if finish
Navigate to Sitecore Content Editor
- Select “Commerce” tab in Sitecore menu
- Click on “Delete Data Templates”
- Click on “Update Data Templates”
Navigate to “Database Cleanup” ([your instance] /sitecore/admin/DBCleanup.aspx)
- Select master and web databases
- Select all tasks except “Cleanup Blobs”
- Click on “Execute Cleanup”
Navigate back to Sitecore Content Editor
- Publish Catalog generated templates (/sitecore/templates/Commerce/Catalog Generated)
- Publish Catalogs node (in my case it’s /sitecore/Commerce/Catalog Management/Catalogs)
- Alternatively, instead of 1 and 2 you can just publish entire site, but it’s not necessary, above nodes is all that need to be published
- Rebuild indexes, run iisreset if needed