Walkthrough: Preparing Sitecore for synchronizing a text file
This walkthrough is part one of Synchronizing data from a text file to Sitecore walkthrough series and describes how to prepare for constructing a data synchronization of a text file.
The walkthrough describes how to:
-
Create a text file with test data
-
Create a tenant in Sitecore
-
Create a target item template
-
Add a parent item for target items
Create a text file with test data
This example source file contains information about cities. Each row in the file represents a different city. The first line in the file contains the names of the columns in the file.
You only need this file in order to complete the walkthrough series. It has no purpose other than as an example.
To create this source file in Data Exchange Framework:
-
Create a new file, for example,
C:\Sitecore\cities.datImportantYou can place this file wherever you want, but it must be accessible from your Sitecore server. This includes file permissions.
-
Add the following text to the file:
RequestResponseid,country,city fr1,France,Paris dk1,Denmark,Copenhagen jp1,Japan,Tokyo us1,United States,New York us2,United States,Los Angeles -
Save the file.
Create a tenant in Sitecore
A tenant is the parent item for all of the settings related to a set of related data synchronization processes. In this example, you use a tenant to group the settings needed to read data from a text file and to create Sitecore items from that data.
To add a tenant:
-
In the Content Editor, navigate to /sitecore/System/Data Exchange.
-
On the ribbon, on the Home tab, click Empty Data Exchange Tenant to add a new tenant, and name it File System Provider Test Tenant. Click OK.
NoteWhile Sitecore is creating the tenant, it displays the progress in the Creating tenant dialog.
-
When the tenant has been created, in the content tree, select the new tenant, for example, sitecore/System/Data Exchange/File System Provider Test Tenant.
-
On the Content tab, select the Enabled check box.
-
Save the item.
Create a target item template
In this walkthrough each row from the source text file represents information about a city. The data synchronization process maps the data from the text file to a Sitecore item. In order to store this information you must create a Sitecore template to store this information, add an icon to the template, and assign the data fields to the template.
To create a template:
-
In the Content Editor, navigate to Templates. On the menu ribbon, on the Home tab, in the Insert group, click New Template.
-
In the Select name dialog, enter the following values:
Name
City Information
Base template
Templates/System/Templates/Standard Template
-
Click Next.
-
In the Location dialog, select Templates/User Defined. Click Next. In the confirmation dialog, click Close.
-
To set an icon for the new template, in the content tree, select the template, for example, Templates/User Defined/City Information.
-
In the right-hand pane, on the Content tab, click the icon next to title.
-
In the Change Icon dialog, in the Icon field, enter, for example,
Office/32x32/pin.png -
To add fields to the template, on the Builder tab, type Data in the Add a new section field.
-
In the Data section, add the following fields:
Name
Type
Shared
Identifier
Single-Line Textselected
Country
Single-Line TextCity
Single-Line TextWhen you have finished, the section looks like the following:
-
Save the item.
Add a parent item for target items
The data synchronization process creates a Sitecore item for each row in the text file. These target items represent, for example, the cities described in the text file. The data synchronization adds the city items as child items under a Sitecore parent item.
You must create the parent item before the synchronization can create the child items.
To add a parent item:
-
In the Content Editor, navigate to /sitecore/Content.
-
On the ribbon, on the Home tab, in the Insert group, click Insert from template.
-
In the Insert from Template dialog, in the Template field, select Templates/Common/Folder. In the Item Name field, enter Cities.
-
Click Insert.