Sitecore tips and tricks and community news !

Post Top Ad

Post Top Ad

Showing posts with label templates. Show all posts
Showing posts with label templates. Show all posts
12:30 PM

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 !

1:55 PM

Sitecore + SXA + xCommerce - Azure ASE custom ARMs deployment

Hello fellows,

Today I would like to talk about custom deployment of Sitecore 9.0.2 + SXA  + xCommerce  on Azure PaaS - but here we have to add something more ASE support. I got a case from client to make it in isolated way and this approach was the most acceptable by them.

Because they have used Sitecore 9.0.2 we have to work with this version, which needs our custom work to achieve Azure ASE on Sitecore ARMs files.



But somebody will ask, bro, what is this Azure ASE?

From MS site (more Microsoft Docs - Azure ASE):

The Azure App Service Environment is an Azure App Service feature that provides a fully isolated and dedicated environment for securely running App Service apps at high scale. This capability can host your:
  • Windows web apps
  • Linux web apps
  • Docker containers
  • Mobile apps
  • Functions
App Service environments (ASEs) are appropriate for application workloads that require:
  • Very high scale.
  • Isolation and secure network access.
  • High memory utilization.
Customers can create multiple ASEs within a single Azure region or across multiple Azure regions. This flexibility makes ASEs ideal for horizontally scaling stateless application tiers in support of high RPS workloads.
ASEs are isolated to running only a single customer's applications and are always deployed into a virtual network. Customers have fine-grained control over inbound and outbound application network traffic. Applications can establish high-speed secure connections over VPNs to on-premises corporate resources.
First of all I have to remind where we can find Sitecore ARM templates:



I was digging this topic and I what I got to know more is which ARMs attribute we have to use. The main one are:
  • server farm
  • hosting environment profile
Where we can find them? -> In infrastructure files of Sitecore

I will make here some out off topic, but I recommend to use ARM templates extension for VSCode, check this out:


Take a look on Sitecore ARM infrastructure.json file


But you have to be aware that there is more than 1 place to switch :)

What you can do more is for instance change default Azure App Service Plan usage. Of course not on a production stage, but if you are building only kind of PoC, you don't need all PaaS App Service Plans (which on ASE costs much). You can e.g. create only one for PoC purpose like I said.

What I would like to highlight is that this parameters values we can also pass from the top, what means parameters.json file. In that way we will keep all values in one place.


The same situation is with xCommerce ARMs template, which have similar structure to Sitecore ARMs templates


Because we knowe already, from where we can get default ARMs for Sitecore I will put here only infrastructure files for Sitecore 9.0.2 and xCommerce 9.0.3 to help understand how to use this paramas.
I would like to notice that my custom templatea are only for PoC purposes and I have changed number of App Service Plans. In the other hand, it will be also a good example for you.


Cheers!