Commerce Engine environments


Overview of environments that are used when you want to have separate configurable pools of data and service functionality running in a single-server instance.

Sitecore XC uses the concept of environments to allow for different configuration behavior. Commerce environments provide the ability to have separately configurable pools of data and service functionality, running in a single-service instance.

An environment in Sitecore XC refers to a collection of configuration policies that defines behavior, for example, how a call to the engine is handled. You can therefore tailor Commerce Engine functionality according to the requirements of an environment. Identical engine calls (for example, a request for product details) can function differently depending on the environment identifier specified in the call header.

For example, you can configure different caching behavior between environments, to reflect the level of traffic expected for each Commerce Engine service.

In this scenario, if the Commerce Engine receives a request for product details from a Shops environment, the data would likely be read from a cache, to minimize the impact on performance. However, if the Authoring environment is specified in the call header, the Commerce Engine would likely retrieve the data directly from the database, to provide the most up-to-date information.

You define a Commerce environment in the environment configuration JSON file. The environment JSON file contains information on specific Commerce Engine policies, either as references to policy sets outside the JSON file or as explicit policy configuration within the file, to be implemented only for that environment itself. This policy information in the file determines Commerce Engine behavior when handling calls that reference the environment's ID in the call header.

The following is an example of a reference to the Caching policy set within the "Policies" collection of an environment JSON file:

     "$type": "Sitecore.Commerce.Core.PolicySetPolicy, Sitecore.Commerce.Core",
     "PolicySetId": "Entity-PolicySet-CachingPolicySet"

The Sitecore XC solution includes several environment configuration files for the sample Adventure Works shop and sample Habitat shop in the Sitecore.Commerce.Engine.*.zip package (in the wwwroot\data\Environments folder):

  • Adventure Works

    • Plugin.AdventureWorks.CommerceAuthoring-1.0.0.json

    • Plugin.AdventureWorks.CommerceShops-1.0.0.json

    • Plugin.AdventureWorks.CommerceMinions-1.0.0.json

  • Habitat

    • Plugin.Habitat.CommerceAuthoring-1.0.0.json

    • Plugin.Habitat.CommerceShops-1.0.0.json

    • Plugin.Habitat.CommerceMinions-1.0.0.json

The differences in configuration between these default environments reflect the intended purpose for each one.

For example, in the Authoring environment, the PromotionsRequireApproval parameter (in the Global Promotions policy) is set to false because business users are usually testing promotions in this environment and do not require approval to publish them. In the Shops environment, however, this same parameter is set to true, so that a business user cannot publish a promotion to a shop without approval from the appropriate business user (the Promotion Manager role).

Configuration file settings

You can also create your own environment and customize the configuration as required.

Environments can share the same persistent store as other environments or be separated into their own exclusive persistent store.

Every environment has an Artifact Store ID, which is a key that the Commerce Engine stores data against. The Artifact Store ID defines the set of data that any calls to the Commerce Engine (for that environment) work against.

For example, the Sitecore XC solution includes default environments for two different sample shops, the Habitat shop and the Adventure Works shop. There are separate configuration files for the environments under each shop, as follows:

  • HabitatAuthoring

  • HabitatShops

  • AdventureWorksAuthoring

  • AdventureWorksShops

The HabitatAuthoring and HabitatShops environments share the same artifact store ID, as declared in their JSON files: