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?
Use 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
.