Synchronize content items

Abstract

How to synchronize data between the Sitecore Content Editor and the Commerce Engine after you create a new Commerce content items (such as custom Commerce Terms), so that it is displayed in the Business Tools user interface, for example.

When you add a new Commerce content item or make changes to an existing one in the Commerce Control Panel (in the Sitecore Content Editor), you must synchronize the content item (defined in the Sitecore Content Editor) with the data in the Commerce Engine database. For example, if you add a new Commerce Term (a new item to display to Business Tools users, for example), you must synchronize the new content item so that it can be displayed on the Business Tools user interface.

You can synchronize a single content item using the Sync content item sample API request. If there are more than one new or modified content items, then you need to synchronize all content items by using the Sync content path sample request. Both requests are available in the Postman sample collections that are included in the Sitecore Commerce Engine SDK.  

Synchronize a single content item

You can use the Sync content item sample request in Postman when you have a single Sitecore content item to synchronize.

Prerequisites

Before you use the Sync content item request in Postman, make sure to have the Sitecore content item path (URL) at hand. You need to pass this information as a parameter value when invoking the Sync content item request in Postman. The following shows an example of the Contentth (URL) of a Commerce content item in the Sitecore Content Editor.

Commerce_Content_Item_path.png

To synchronize a content item between the Sitecore Content Editor and the Commerce Engine:

  1. Open Postman and, in the Postman Collections pane, expand the ContentAPISamples collection.

  2. Open the Views folder, and click on the Sync item request.

  3. In the Body pane, ensure the values for the viewName and forAction parameters are both set to SynchronizeContentItem, and click Send.

    Note

    The Sync item request returns information on the Entity View. In the properties section for the "Version" , take note of the "Value" (shown in the following example). You must provide this information as input in a subsequent step in the Sync content item request.

    SyncContentPath_Version_value.png
  4. Open the DoActions folder, and click on the Sync content item request.

  5. In the Body pane, update the "Version" with the value returned in the previous step, and update the "Path" property value with the content item path (URL) of the custom Commerce item to synchronize. The following shows an example of the property values you need to update.

    Views_version_and_path.png
  6. Click Send.

  7. Open IIS Manager and restart the Commerce Engine site, to clear the Commerce Engine cache. 

Synchronize all content items in the Control Panel

When the Commerce Control Panel (in Sitecore Content Editor) contains multiple custom Commerce items, you use the Sync content path API sample to synchronize all Commerce content items.

Note

This operation deletes all Control Panel content items from the Commerce Engine, then re-copies content items from Sitecore Commerce Control Panel into the Commerce Engine content tables. The number of content items to synchronize determines the time this operation takes to complete.

To synchronize all content items:

  1. In the Postman Collections pane, expand the ContentAPISamples collection.

  2. Open the Views folder, and click on the Sync item request.

  3. In the Body pane, ensure the values for the "viewName" and "forAction" parameters are set to SynchronizeContentPath, and click Send.

    Note

    The Sync item request returns information on the Entity View. Take note of the content item "Version" value, as you must provide this information as input in the Sync content path request.

    SyncContentPath_Version_value.png
  4. Open the DoActions folder, and click on the Sync content path request.

  5. In the Body pane, update the version "Value" property with the same value as the one returned in the response to the Sync item request performed in Step 3

    The following shows an example of the "Version" property you must update in the Sync content path request :

    SyncItemPath.png
  6. Click Send.

  7. Open IIS Manager and restart the Commerce Engine site, to clear the Commerce Engine cache.