I am using Sitecore XC 9.1 and want to programmatically trigger a update of the Commerce data templates. This will, for example, be handy in my CI setup.
How to do this?
Sitecore Stack Exchange is a question and answer site for developers and end users of the Sitecore CMS and multichannel marketing software. It only takes a minute to sign up.
Sign up to join this communityUse the CatalogTemplateGenerator
class to perform the desired actions, e.g. to delete and build:
var master = Sitecore.Configuration.Factory.GetDatabase("master");
var generator = new Sitecore.Commerce.Engine.Connect.DataProvider.Templates.CatalogTemplateGenerator();
generator.DeleteAllGeneratedTemplates(master);
generator.BuildCatalogTemplates(master);
NB. the GUI triggers this code by Sitecore.Commerce.Engine.Connect.DataProvider.Commands.GenerateTemplatesCommand
.