How to Import/Refresh Catalog from Production to Lower Environment
October 9th 2021
Catalog Import/Refresh from Prod to Lower Environments is one of the recurring requirements/concerns on every Sitecore Commerce project.
This can be very useful, especially for Staging/Pre-Prod Testing, or even troubleshooting on your local environment.
There are many ways to achieve this, from API-based, using Spreadsheets or using SQL Import for example.
After trying many of these options, my choice stopped at Visual Studio SQL Data Comparison Tool.
This process should take between 10 and 30 minutes depending on the size of your catalog.
Catalog Import/Refresh, Step by Step:
Take a Backup of your target Database.
Execute the script below on your target Database to clear all catalog related data. If you need to import orders and customers as well, you will need to add their tables to the script:
delete from sitecore_commerce_storage.CatalogEntities;
delete from sitecore_commerce_storage.CatalogEntity;
delete from sitecore_commerce_storage.CatalogLists;
delete from sitecore_commerce_storage.InventoryEntities;
delete from sitecore_commerce_storage.InventoryEntity;
delete from sitecore_commerce_storage.InventoryLists;
delete from sitecore_commerce_storage.LocalizationEntities;
delete from sitecore_commerce_storage.LocalizationEntity;
delete from sitecore_commerce_storage.Mappings;
delete from sitecore_commerce_storage.PricingEntities;
delete from sitecore_commerce_storage.PricingEntity;
delete from sitecore_commerce_storage.PricingLists;
delete from sitecore_commerce_storage.PromotionsEntities;
delete from sitecore_commerce_storage.PromotionsEntity;
delete from sitecore_commerce_storage.PromotionsLists;
delete from sitecore_commerce_storage.RelationshipLists;
delete from sitecore_commerce_storage.VersioningEntities;
delete from sitecore_commerce_storage.VersioningEntity;
delete from sitecore_commerce_storage.WorkflowLists;
Open Visual Studio and go to Tools>SQL Server>New Data Comparison
Select your source and target Database
Uncheck all the options except 'Only in Source'
Click 'Next' and select same tables included in the script used earlier.
Click 'Finish'
Click 'Update Target'
Clear Commerce Cache using Postman and from Sitecore Admin.
Your source and target environments should now have the same catalog data.
I hope you find this post helpful.
Feel free to leave comments or questions.
Comments