Entity journaling

Current version: 10.3

The Commerce Engine encompasses extensible services that enable you to customize commerce functionality.

Note

Do not extend or inherit from out-of-the-box policies; instead, create your own. You can change the values in a policy by modifying the PolicySet JSON or the Environment JSON, depending on where the policy is defined and then re-running Bootstrap.

When enabled for an entity type, entity journaling sets a flag to update a journal whenever the entity changes. The journaling process saves a complete copy of the previous version of the changed entities, providing a log of all changes.

Note

The journaling entries can considerably increase the size of the Shared Environments database since journaling creates a copy of the complete entity, and not just the changed entity fields or properties. For example, every time an order status changes, a complete copy of the order entity is stored in the database.

Starting with Sitecore 10.1, you can configure the Commerce Engine to archive order journaling entries to help reduce the number of order journaling entries in the Shared Environment database.

Alternatively, you can consider disabling entity journaling for Commerce entities that do not have auditing requirements.

The following policy can be configured through the Journaling plug-in.

Policy

Description

Properties / Default Values

EntityJournalingPolicy

Defines the name of the journals list and the full entity type.

Journal \ "EntityJournal"

EntityFullName\ string.Empty

The following is an example of a EntityJournalingPolicy:

RequestResponse
{
     EntityFullName = "Sitecore.Commerce.Plugin.Orders.Order",
     Journal = "OrdersJournal"
 }

The EntityPersistenceJournalingBlock checks the EntityJournalingPolicy for rules on how to journalize the entity.

Change Commerce Entity journaling configuration

You can enable or disable journaling for a Commerce Entity by changing the EntityJournalingPolicy policy in the Commerce environment configuration file. For example, to change the journaling behavior in the sample Habitat Authoring environment, you modify the wwwroot\CommerceAuthoring_Sc\wwwroot\data\EnvironmentsPlugIn.Habitat.CommerceAuthoring-*.*.*.json file.

To enable journaling, for example, of changes to the Customer entity in the sample Habitat Authoring environment:

  1. Open the wwwroot\CommerceAuthoring_Sc\wwwroot\data\EnvironmentsPlugIn.Habitat.CommerceAuthoring-*.*.*.json file.

  2. In the file, add the EntityJournalingPolicy policy, specify the entity name (EntityFullName), and the journal name:

    RequestResponse
    "$type": "Sitecore.Commerce.Plugin.Journaling.EntityJournalingPolicy, Sitecore.Commerce.Plugin.Journaling",
            "EntityFullName": "Sitecore.Commerce.Plugin.Customers.Customer",
            "Journal": "CustomersJournal"
  3. Save your changes and bootstrap the Commerce Engine.

    Note

    To disable journaling of a given Commerce entity type, delete the corresponding EntityJournalingPolicy policy block from the environment configuration file.

    If journaling is disabled for an entity where it was previously enabled, the journal entries are not removed; it will simply no longer create new ones.

Do you have some feedback for us?

If you have suggestions for improving this article,