These fields are obtained from the ContextInfo. It contains the information about the API request. The very important part to support the multi-tenancy is a ContextRequest. It contains such information as tenantId, catalogId, applicationId, etc.
When you create an entity using our API, it uses com.broadleafcommerce.data.tracking.core.service.CrudEntityHelper#create. Before creating the entity we have to convert the business entity (e.g Product) to the repository domain (JpaProduct). To do so we use a com.broadleafcommerce.data.tracking.core.mapping.DomainMapperManager#fromBusinessDomain mapper. Under the hood, it loops through a list of com.broadleafcommerce.data.tracking.core.mapping.DomainMapperMember implementations and fills in all the necessary data.
The tenant ID is populated in ModelMapperDomainMapperMember. It uses a com.broadleafcommerce.data.tracking.core.mapping.TrackableDomainMapperMemberSupport#buildTracking method to create this information.
The trk_archived is used to indicate whether this particular entry has been archived (soft deleted) in the database. It is also used for versioning purpose.
The trk_change_details is used to store changes across different versions of an entity. For example, you have a Product with its basePrice of 10 EUR and name ‘Test Product’ deployed to production. And let’s say, you change its price to 15 EUR and name to ‘Test Product Premium’. Then the trk_change_details will be like below (other fields of the payload have been omitted for simplicity):
[
{
"fieldName": "name",
"businessFieldName": "name",
"beforeValue": "\"Test Product\"",
"afterValue": "\"Test Product Premium\"",
.
.
.
},
{
"fieldName": "defaultPrice",
"businessFieldName": "defaultPrice",
"beforeValue": "{\"amount\":10.00,\"currency\":\"EUR\"}",
"afterValue": "{\"amount\":15.00,\"currency\":\"EUR\"}",
.
.
.
}
]
Finally, the trk_tenant_id is used to store information about the currently active tenant.