Synchronize content items
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 Content path (URL) of a Commerce content item in the Sitecore Content Editor.
To synchronize a content item between the Sitecore Content Editor and the Commerce Engine:
-
Open Postman and, in the Postman Collections pane, expand the ContentAPISamples collection.
-
Open the Views folder, and click on the
Sync item
request. -
In the Body pane, ensure the values for the viewName and forAction parameters are both set to
SynchronizeContentItem
, and click Send.NoteThe
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 theSync content item
request. -
Open the DoActions folder, and click on the
Sync content item
request. -
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. -
Click Send.
-
To make the content item available the Business Tools, you must flush the Redis cache. Navigate to
C:\Program Files\Redis
, runredis-cli.exe
and execute the flushall command.
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.
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:
-
In the Postman Collections pane, expand the ContentAPISamples collection.
-
Open the Views folder, and click on the
Sync item
request. -
In the Body pane, ensure the values for the
"viewName"
and"forAction"
parameters are set toSynchronizeContentPath
, and click Send.NoteThe
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 theSync content path
request. -
Open the DoActions folder, and click on the
Sync content path
request. -
In the Body pane, update the version
"Value"
property with the same value as the one returned in the response to theSync item
request performed in Step 3The following shows an example of the
"Version"
property you must update in theSync content path request
: -
Click Send.
-
To make the content item available in the Business Tools, you must flush the Redis cache (use the flushall command in Redis).