Changing a Canonical Item During Composition
Existing canonical items can be updated by merging them with incoming items when they share the same integration key. Canonical items can also be deleted with a delete request.
Updating and Merging Existing Canonical Items During Composition
If you have an existing canonical item you wish to update, you can load a raw item to the same pool with the same integration key. Data Hub creates a new, merged canonical item during composition. The new, merged canonical item automatically updates or includes any new attributes passed to it.
Your starting point for the update is a single data pool that holds both the existing canonical items, and the new raw items. Data Hub goes through the following steps to complete the merge and update:
- Current canonical items with a SUCCESS status are updated when new raw items matching their data pool and integration key are composed.
- For each item to be updated, a new merged canonical item is created. Its values are populated by merging the existing canonical item and the just composed raw item. The new, merged canonical item has a status of SUCCESS.
- The status of the old matching canonical item and the just composed raw item are set to ARCHIVED.
Different attributes of the canonical item are merged according to the following rules:
- Single Value Attributes
If an attribute is updated for the just-composed raw item, then the new merged canonical item inherits this update. Otherwise, the value of the old canonical item remains unchanged when set on the new merged canonical item.
- Localized Attributes
When the attribute has localized values, the resulting merged canonical item updates all languages with the new values of the just composed raw item. If the old canonical item contains values for languages that new raw item does not have, those values remain unchanged on the new merged canonical item.
- Collections
When the attribute is a collection, the two collections merge into one collection, and any duplicates that might occur in the combined collection are removed. If the new raw item has an empty collection for its value, the resulting merged canonical item also contains an empty collection value. The empty collection value is created by a raw item with an empty string set for its corresponding raw attribute
Deleting a Canonical Item
A successfully composed canonical item can be deleted when it is not needed. If the item is found and has a canonical item status of SUCCESS, the new status following the delete request is DELETED. The delete is a soft delete in Data Hub, which simply changes the canonical item status to DELETED.
Any canonical item with a status of DELETED is eligible for publication to target systems. When published through Data Hub to a Platform, the Data Hub Adapter extension attempts to remove the item from Platform. The following outcomes are possible:
- The item is successfully deleted from Platform. The item did not exist in Platform. The item's CanonicalItemPublicationStatus is marked as SUCCESS.
- If the deletion of the Item was not Published at all. That is, it was filtered out before publication by a Publication Grouping Handler, the CanonicalItemPublicationStatus of the item is marked as IGNORED.
- If an error is reported during publication to Platform, the CanonicalItemPublicationStatus of the item is marked as FAILURE. Canonical items with a CanonicalItemPublicationStatus of FAILURE remain eligible for publication.
There are several options available for deleting canonical items in Data Hub:
- The Data Hub Outbound Service in Data Hub Adapter (The Data Hub Adapter)
- The delete REST methods in the Data Hub API (REST API)
- The delete methods in the CanonicalItemService in the Data Hub SDK. See the JavaDoc provided with the SDK for documentation of these methods.
If a new canonical item enters Data Hub with the same integration key as an existing canonical item marked DELETED, it is considered a new item. It is not merged and only the new item is published.
Deleting a Canonical Item on a Non-SAP Commerce Cloud Target
You can also use the DELETE status to delete items from a non-SAP Commerce Cloud target system by implementing this capability in your custom target adapter. See Using the Publish Method.