allBlogsList

SXC9 One way to deal with Sitecore Commerce Templates going out of sync

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)

  1. Switch to web database

  2. 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

  3. Click on “Delete Children” and give it few minutes to finish

  4. Navigate to /sitecore/templates/Commerce/Catalog Generated

  5. Click “Delete”, let if finish


Navigate to Sitecore Content Editor

  1. Select “Commerce” tab in Sitecore menu

  2. Click on “Delete Data Templates”

  3. Click on “Update Data Templates”


Navigate to “Database Cleanup” ([your instance] /sitecore/admin/DBCleanup.aspx)

  1. Select master and web databases

  2. Select all tasks except “Cleanup Blobs”

  3. Click on “Execute Cleanup”


Navigate back to Sitecore Content Editor

  1. Publish Catalog generated templates (/sitecore/templates/Commerce/Catalog Generated)
  2. Publish Catalogs node (in my case it’s /sitecore/Commerce/Catalog Management/Catalogs)
  3. 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
  4. Rebuild indexes, run iisreset if needed