Make Commerce entity properties localizable

Abstract

How to make the properties of a Commerce entity localizable.

You can make the properties of a commerce entity localizable by adding a LocalizeEntities policy to the PlugIn.LocalizeEntities.PolicySet-1.0.0.json file. For a description of the LocalizeEntities policy, see the LocalizeEntities policy set.

Note

You can use the following procedures to expose any properties of default Business Tools views and child views, but also to expose properties you implement in your custom plugin.

Entity view properties you create using Composer are not localizable.

In the Merchandising tool, the default sellable item Summary view contains the child view Item Specifications with some default properties. The Item Specifications properties are not localizable by default, that is, the PlugIn.LocalizeEntities.PolicySet-1.0.0.json does not contain any policy specifying that child view. The following example shows how to make some of the Item Specifications properties localizable, specifically at the sellable item level, and then also at the sellable variant level.

To make properties of the Item Specifications child view localizable at the sellable item level only:

Note

The policy configuration must specify the exact property names. If you are unsure of the exact property names, you can use Postman to send a request to get the entity view, and then verify the names of the properties that are returned within the response.

  1. Open the wwwroot\<CommerceEngineService>\wwwroot\data\Environments\PlugIn.LocalizeEntities.PolicySet-1.0.0.json file.

  2. In the file, locate the existing entity type "Type": "Sitecore.Commerce.Plugin.Catalog.SellableItem", under the "ComponentsPolicies" section, and add an instance of the LocalizeEntityComponentPolicy policy, as shown in the following example:

     {
        "$type": "Sitecore.Commerce.Core.LocalizeEntityPolicy, Sitecore.Commerce.Core",
        "Type": "Sitecore.Commerce.Plugin.Catalog.SellableItem",
        "Properties": [
          "DisplayName",
          "Description",
          "Brand"
        ],
        "ActionView": "Details",
        "ComponentsPolicies": [
          {
             "$type": "Sitecore.Commerce.Core.LocalizeEntityComponentPolicy, Sitecore.Commerce.Core",
             "Path": "ItemSpecificationsComponent",
             "Properties": [
                "WeightUnitOfMeasure",
                "DimensionsUnitOfMeasure"
                "SizeOnDiskUnitofMeasure"
                ],
                "ActionView": "ItemSpecifications",
                "IsItemComponent": false
           },
     }

    Note

    The "IsItemComponent": false property indicates that the listed child view properties are only localizable at the sellable item level. In this case, sellable variants inherit the localized property values from the sellable item entity.

    To make the properties localizable at the item variant level only (and not at the sellable item entity level), set "IsItemComponent": to true.

  3. Bootstrap the Commerce Engine to register your configuration changes.

Make a property localizable at the sellable item level and the variant level

You can also set up the policy configuration so that properties are localizable both at the sellable item level, and at the variant level independently. Although this an unlikely scenario for the properties of the Item Specifications, you can use this as an example for other view properties as required.

To make properties of the Item Specifications properties localizable both at the sellable item and at the item variant level:

  1. In the wwwroot\<CommerceEngineService>\wwwroot\data\Environments\PlugIn.LocalizeEntities.PolicySet-1.0.0.json file, add a policy at the sellable item level ("Path":"ItemSpecificationsComponent"), and another one at the item variant level ("Path": "ItemVariationsComponent.ItemVariationComponent.ItemSpecificationsComponent"), and set the "IsItemComponent" property to "true", for example:

     {
        "$type": "Sitecore.Commerce.Core.LocalizeEntityPolicy, Sitecore.Commerce.Core",
        "Type": "Sitecore.Commerce.Plugin.Catalog.SellableItem",
        "Properties": [
          "DisplayName",
          "Description",
          "Brand"
        ],
        "ActionView": "Details",
        "ComponentsPolicies": [
          {
             "$type": "Sitecore.Commerce.Core.LocalizeEntityComponentPolicy, Sitecore.Commerce.Core",
             "Path": "ItemSpecificationsComponent",
             "Properties": [
                "WeightUnitOfMeasure",
                "DimensionsUnitOfMeasure"
                "SizeOnDiskUnitofMeasure"
                ],
                "ActionView": "ItemSpecifications",
                "IsItemComponent": false
           },
           {
             "$type": "Sitecore.Commerce.Core.LocalizeEntityComponentPolicy, Sitecore.Commerce.Core",
             "Path": "ItemVariationsComponent.ItemVariationComponent.ItemSpecificationsComponent",
             "Properties": [
                "WeightUniOfMeasure",
                "DimensionsUnitOfMeasure"
                "SizeOnDiskUnitofMeasure"
                ],
                "ActionView": "ItemSpecifications",
                "IsItemComponent": true
           },
    }
    
  2. Bootstrap the Commerce Engine to register your configuration changes.