Entity archiving
Entity archiving allows the Commerce Engine to move eligible, inactive Commerce entities stored in the Shared Environments database, to an archive database. Pruning the Shared Environments database of unnecessary entity prevents the database from expanding to an unmanageable size, and effectively reduces the number of entities that Commerce operations must iterate through when processing requests.
Entity archiving is performed by archive entity minions. Each entity type to archive requires its own distinct archiving minion defined in the Plugin.Minions.PolicySet-1.0.0.json
file. The archive entity minion runs as a scheduled process, and moves eligible inactive entities from the SitecoreCommerce_SharedEnvironments database, to the SitecoreCommerce_ArchiveSharedEnvironments database.
Entity archiving is disabled by default for all Commerce entity types. You can enable entity archiving for each Commerce entity type separately, on a per-environment basis, by updating the appropriate entity archiving policy located in the wwwroot/data/Environments/PlugIn.<Environment>.CommerceMinions-1.*.*.json
file.
The Commerce Engine supports archiving of the following entities, based on eligibility criteria defined by policies:
-
Completed or cancelled orders, along with related sales activities and indexes.
NoteArchived orders are not visible to Business Tools users and do not come up in searches.
-
Order journal entries.
Archiving very large amount of data can impact the performance of the SQL service. Consider these recommendations and best practices for archiving minions configuration before you enable entity archiving.
Entity archiving policies
Entity archiving policies define the criteria that determine whether an entity is eligible for archiving and to enable or disable entity archiving for an entity type. Entity archiving policies are configurable in the environment policy set JSON file for the minions service, for example, wwwroot/data/Environments/PlugIn.Habitat.CommerceMinions-1.*.*.json
.
ArchiveEntityPolicy
The ArchiveEntityPolicy
is a generic policy that contains properties that define the eligibility criteria for archiving entities of a given type.
The following shows an example of the default ArchiveEntityPolicy
policy defined for archiving journal entries:
{ $type": "Sitecore.Commerce.Plugin.Archive.ArchiveEntityPolicy, Sitecore.Commerce.Plugin.Archive",
"TypeFullName": "Sitecore.Commerce.Plugin.Journaling.JournalEntry, Sitecore.Commerce.Plugin.Journaling",
"IsEnabled": false,
"EntityThreshold": 60,
"BatchCount": 500
The properties of the "Sitecore.Commerce.Plugin.Archive.ArchiveEntityPolicy"
are:
Property |
Description |
---|---|
|
The full name of the Commerce entity type. |
|
Whether the archiving for this entity type is enabled or not. By default, entity archiving is disabled ( |
|
The number of days since the entity was last updated (DateUpdated), after which it is eligible for archiving. By default, entities are eligible for archiving after 60 days. |
|
The maximum number of entities to process per batch. By default, the maximum number of entities per batch is 500. |
Archive order policy
The Commerce Engine automatically archives inactive orders based on their status, and when they become eligible for archiving. The Archive order policy is used specifically to define eligibility criteria for archiving inactive order entities.
When an inactive order is archived, all EntityIndexe
and SalesActivity
entities related to the eligible order are also moved to the archive database.
The following shows an example of the default Sitecore.Commerce.Plugin.Archive.ArchiveOrderPolicy
policy defined in the sample PlugIn.Habitat.CommerceMinions-1.*.*.json
file:
{ "$type": "Sitecore.Commerce.Plugin.Archive.ArchiveOrderPolicy, Sitecore.Commerce.Plugin.Archive", "TypeFullName": "Sitecore.Commerce.Plugin.Orders.Order, Sitecore.Commerce.Plugin.Orders",
"OrderStatusList": [ "Completed", "Cancelled" ],
"EntityThreshold": 60,
"IsEnabled": false,
"BatchCount": 500
},
The properties of the Sitecore.Commerce.Plugin.Archive.ArchiveOrderPolicy
are:
Property |
Description |
---|---|
|
The lists that the archiving minion watches, each corresponding to the status of orders that can be archived. By default, orders that are in the completed or cancelled status are eligible for archiving. Warning When adding to the |
|
Whether the archiving for this entity type is enabled or not. By default, entity archiving is disabled ( |
|
The number of days an order must be in the eligible status (for example completed or cancelled) before the minion archives it. By default, an order is archived after 60 days. |
|
The maximum number of entities to process per batch. |