Walkthrough: Configuring Related Entity Mapping to retrieve all related entities
In Content Hub, when a CMP item has several items attached, the Related Entity Mapping in Sitecore only retrieves the first CMP asset. It does not retrieve the other related entities. This walkthrough explains how to retrieve all assets attached to a CMP item in Content Hub, so that they become available in Sitecore.
This walkthrough describes how to:
-
Create a template for the entity's field
-
Create the buckets for the templates previously created
-
Create an entity mapping
-
Create the field mapping
-
Create the related entity mapping
-
Sync the entities
-
Rebuild Sitecore search indexes
Create a template for the entity's field
This procedure shows the steps to create a template for a CMP entity's field.
To create a template for an entity's field:
-
In the Content Editor, go to
/sitecore/templates/, right click, then click Insert > New Template. -
Enter a template name, for example, Products.
-
Create a new field for the Related Entity Mapping to use later.
The following example creates a new field named ProductImage, with the field type Multilist:
-
To add a template for a CMP entity's field, on the Content tab, in the Data section, click CMP, and then double-click Content Hub Entity.
NoteTo add a template for a DAM entity's field, click DAM, and then double-click Content Hub Entity.
The Content Hub Entity base template is now included in the selected templates list, for example:
-
Repeat these steps for all required entity's field.
Create item buckets for the new templates
In Sitecore, item buckets let you manage large numbers of items in the content tree. Create a bucket for each template you created in the previous step.
To create a bucket:
-
In Content Editor, go to
/sitecore/Content/CMP. -
Right-click on the CMP item, click Insert > Bucket.
-
Enter a name for the new bucket item. For example, Assets , or Products.
Create entity mappings
Entity Mapping items allow you to sync Content Hub entities of a given content type. Create an entity mapping for each template you previously created.
To create an entity mapping:
-
Navigate to
/sitecore/system/Modules/CMP/Config, right-click, and click Insert, then click Entity Mapping. -
Enter a name for the entity mapping, for example, Products.
-
Fill in the field values for the entity mapping. For example:
-
Repeat these steps for each entity mappings as required, for example for the Assets entity.
Create the field mappings
A Field Mapping in Sitecore contains the name of the field in the Content Hub entity to the name of the field in a Sitecore item. To create the field mappings:
-
Right-click one of the entity mappings you created previously, for example Products, click Insert, then click Field Mapping.
-
Fill in the values for the CMP Field Name and the Sitecore Field Name.
-
Repeat these steps for each field to map.
Create the related entity mapping
To create the related entity mapping:
-
Right-click one of the entity mappings you created previously, click Insert > Related Entity Mapping.
-
Repeat these steps for each entity mapping.
Synchronize the entities
After you have created the necessary items in the Content Editor, you can synchronize the entities from Content Hub to Sitecore. The entity will display related entity mappings, if there are any. For example, the Assets entity that was synced to Sitecore and that is related to the Products entity will appear in the ProductImage field.
To sync the entities:
-
In the Content Editor, on the ribbon, click DAM.
-
In the content tree, click the item field you want to synchronize with the DAM asset property.
NoteThe field must be of type Image or Link.
-
On the ribbon, click Sync, and then in the drop-down menu, do one of the following:
-
To synchronize only the properties of the selected field, click Sync Current.
-
To synchronize the properties of all children under the selected target item, click Sync Children.
-
-
In the DAM Batch Sync dialog, click Next, and verify that the Target Item field displays the correct item to synchronize.
-
Click Start Batch Sync.
The entity with the related entity mapping will display entities that it is related to. For example, the Assets entity that was synced to Sitecore and that is related to the Products entity now appears in the ProductImage field, as shown in the following example:
Rebuild the Sitecore indexes
To rebuild the Sitecore indexes:
-
Browse to your Sitecore URL, for example,
https://xp1cm.localhost/and open the Control Panel. -
In the Indexing section, click Polulate Solr Managed Schema.
-
In the Schema Populate dialog, click Select All, then click Populate.
Wait for the process to finish.
-
On the Control Panel, in the Indexing section, click Indexing Manager. In the Indexing Manager dialog, select the following indexes:
-
sitecore_master_index -
sitecore_core_indexsitecore_core_index -
sitecore_web_index -
sitecore_marketing_asset_index_master -
sitecore_marketing_asset_index_webdatabases
-
-
Click Rebuild. When the indexes have been rebuilt, click Close.