Sitecore tips and tricks and community news !

Post Top Ad

Post Top Ad

Sitecore xCommerce product items lose composer templates


When we are using xCommerce we have products representation from xCommerce also on Sitecore side. You can see this products as an items with whole description as it usual has. There is also field describing template of an particular item. It should indicate to the product xCommerce template. 

In our scenario we had custom product templates because of our custom composers. Hence in Sitecore we see this custom templates as a definition of particular product (it consist custom product fields inside).

 


Issue

However, from time to time, randomly, this templates just... disappear. Since that moment Sitecore recognize this products as a default ones, described by default xCommerce product template.

That cause the issue with indexing, because custom fields weren't seen and indexed. What mean disaster for proper working application.

Walkaround

As a walkaround you can clear Commerce cache which push Sitecore to refresh xCommerce templates and get proper one. 


 

Unfortunately it doesn't mean it will work since that moment to infinity ;) It can broke one more time randomly.

So what we can do?

 

Solution

It's connected with CatalogRepository.CheckTemplatesMapping() method. When commerce items are loading this method is started.

 

After instance is restarted, when commerce items are loaded from Content Editor (when we navigate to catalog items in Content Editor) then Context.ContentDatabase is not null and there is possibility to load information about custom composer templates. 

 

But, if we open commerce items on Storefront after instance was restarted, before they are opened in Content Editor,  Context.ContentDatabase is null on Storefront. 
Hence, correct composer templates are not possible to load. 

 

Solution is to open CE and set up in path '/sitecore/content/<StorefrontTenant>/<Storefront>/Settings/Site Grouping/Storefront' new property "content" to 'Other properties' with "master" value. 


 

That will give us always filled database context.

Thanks !

No comments:

Post a Comment