Restoring the Shared Environments database in Sitecore Experience Commerce results in catalog corruption


Description

Restoring the Shared Environments database in Sitecore Experience Commerce might result in catalog corruption if the ParentId for the Catalog entry in the Mappings table differs from the ID of the Catalogs item in the Master database. The issue can occur in the following cases:

In both cases, the parent ID of the catalog entry in the mapping table will be different from the ID of the Catalogs Item ID in the Master DB.

There are the following symptoms:

When experiencing these symptoms, first check the following:

  1. Run the SQL query:
    SELECT *
    FROM [Your_SharedEnvironments].[sitecore_commerce_storage].[Mappings]
    where EntityId like '%entity-catalog%'
  2. Check the parent ID for these entries.
  3. Check the ID of the catalogs item in the content tree. The default path to the item is /sitecore/content/Sitecore/Storefront/Home/Catalogs.
  4. The Parent ID and the ID of the Catalogs item must be identical.
    If the ID is different, it means that the mapping table does not store the correct value and the catalog cannot bind to Sitecore.

Solution

To resolve the issue, consider the following solution:

  1. Be sure to back up the Shared Environments database before continuing.
  2. Run the following query for Shared Db to remove the old (invalid) ParentId:
    DELETE
    FROM [Your_SharedEnvironments].[sitecore_commerce_storage].[Mappings]
    WHERE EntityId = 'Entity-Catalog-[Catalog name from query above]' AND ParentId = '[Invalid Parent Id from query above]'
  3. Open the CM server and click Refresh Commerce Cache from the Commerce tab. Then, click Delete Data Templates and Update Data Templates.
  4. Try to save the Catalog under the Catalogs item. If the Catalog opens correctly, rebuild the master and web indexes.
  5. If the issue still exists, restart the CM server to rule out caching issues and repeat step 4.