Samples > Data load utility samples > Examples: Mapping data > Examples: Mapping catalog data > Examples: Mapping category data
Example: Categories
You can insert, replace or delete the category data simultaneously using the data load utility. These examples uses a CSV file to demonstrate how to insert, replace, or delete the categories data.
CSV file column definitions
- GroupIdentifier
- Required: (String) The category identifier. This field cannot be null, and it must be unique.
- TopGroup
- (Boolean) Indicates if this is a top-level category, meaning there are not parent categories.
- TRUE
- top-level category
- FALSE or blank
- subcategory
- ParentGroupIdentifier
- (String) The parent identifier of this category. Leave empty for top-level category.
- Sequence
- (Double) An optional number used to control the order in which child categories are displayed in a parent category.
- Name
- (String) The language sensitive display name of this category.
- ShortDescription
- (String) A language sensitive short description of this category.
- LongDescription
- (String) A language sensitive long description of this category.
- Thumbnail
- (String) The language sensitive thumbnail image path of this category. Use forward slashes (/) in the path, for example images/G1.jpg.
- FullImage
- (String) The language sensitive full image path of this category. Use forward slashes (/) in the path, for example images/G1.jpg.
- Published
- (Integer) The language sensitive value that determines whether to display this category in the storefront.
- 1
- Published. The default value. The category is displayed in the storefront.
- 0
- Not published
- Keyword
- (String) A language sensitive keyword used for searching. Enclose multiple keywords in double quotation marks separated by commas, for example "keyword 1, keyword 2, keyword3".
- Delete
- (String) Indicates whether to delete. If you are performing a delete operation, specify this column. A value of "1", indicates that the row should be deleted.
Other optional fields not included in the example are:
- storeIdentifier
- (String) The identifier of the store that the category belongs to. This column is only needed if the category belongs to a store which is different from the store defined in BusinessContext elements of either the wc-dataload.xml configuration file or the catalog group loader configuration file. If this column is not provided in the CSV file, the StoreIdentifier in the business context is used.
- parentStoreIdentifier
- (String) The Store identifier the parent category belongs to. Use this field when using the extended sites model, where the parent store is different from the store the new category is being added to.
- Note
- (String) Use this field to add footnotes or extended long descriptions for this category.
- Field 1
- (String) A user defined field available for customization purposes.
- Field 2
- (String) A user defined field available for customization purposes.
CSV file with sample category data
Insert or replaceThe sample file contains category data CSV file with sample category data
Formatted CSV file with column headings
GroupIdentifier TopGroup ParentGroupIdentifier Sequence Name ShortDescription LongDescription Thumbnail FullImage Published Keyword TV_category true TV category TV short description TV long description TV_thumb/image.jpg TV_full/image.jpg 1 TV Keyword LCD_category false TV_category 1 LCD TV LCD TV short description LCD TV long description LCD_TV_thumb/image.jpg LCD_TV_full/image.jpg 0 LCD Keyword Appl_category true Appliances category Applicance short description Appliances long description app_thumb/image.jpg app_full/image.jpg 1 Appliances Keyword Fridge_category false Appl_category 2 Refrigerators Refrigerator short description Refrigerator long description fridge_thumb/image.jpg fridge_full/image.jpg 1 Refrigerator Keyword
DeleteTo delete a category, add a Delete column to the CSV file. In this example the data source is a CSV file. The file contains sample category data. Rows where the flag is set to 1 in the Delete column will have the associated category deleted, and rows that do not have anything in the Delete column will have the associated categories inserted or replaces, depending on whether or not pervious data exists in the database. CSV file with sample category data
Formatted CSV file with column headings
GroupIdentifier TopGroup ParentGroupIdentifier Sequence Name ShortDescription LongDescription Thumbnail FullImage Published Keyword Delete TV_category true TV category TV short description TV long description TV_thumb/image.jgp TV_full/image.jgp 1 TV Keyword 1 LCD_category false TV_category 1 LCD TV LCD TV short description LCD TV long description LCD_TV_thumb/image.jpg LCD_TV_full/image.jpg 0 LCD Keyword 1 Appl_category true Appliances category Appliance short description Appliances long description app_thumb/image.jpg app_full/image.jpg 1 Appliances Keyword Fridge_category false Appl_category 2 Refrigerators Refrigerator short description Refrigerator long description fridge_thumb/image.jpg fridge_full/image.jpg 1 Refrigerator Keyword
Map data
The following code snippet from the catalog group loader configuration file demonstrates how to map each value to a business object logical schema path.
<_config:DataMapping> <_config:mapping xpath="CatalogGroupIdentifier/UniqueID" value="GroupUniqueId" /> <_config:mapping xpath="CatalogGroupIdentifier/ExternalIdentifier/GroupIdentifier" value="GroupIdentifier" /> <_config:mapping xpath="ParentCatalogGroupIdentifier/UniqueID" value="ParentGroupUniqueId" /> <_config:mapping xpath="CatalogGroupIdentifier/ExternalIdentifier/StoreIdentifier/ExternalIdentifier/NameIdentifier" value="StoreIdentifier" valueFrom="InputData" /> <_config:mapping xpath="ParentCatalogGroupIdentifier/ExternalIdentifier/GroupIdentifier" value="ParentGroupIdentifier" /> <_config:mapping xpath="ParentCatalogGroupIdentifier/ExternalIdentifier/StoreIdentifier/ExternalIdentifier/NameIdentifier" value="ParentStoreIdentifier" valueFrom="InputData" /> <_config:mapping xpath="topCatalogGroup" value="TopGroup" /> <_config:mapping xpath="displaySequence" value="Sequence" /> <_config:mapping xpath="Description[0]/Name" value="Name" /> <_config:mapping xpath="Description[0]/ShortDescription" value="ShortDescription" /> <_config:mapping xpath="Description[0]/LongDescription" value="LongDescription" /> <_config:mapping xpath="Description[0]/Thumbnail" value="Thumbnail" /> <_config:mapping xpath="Description[0]/FullImage" value="FullImage" /> <_config:mapping xpath="Description[0]/Attributes/published" value="Published" /> <_config:mapping xpath="Description[0]/Keyword" value="Keyword" /> <_config:mapping xpath="Description[0]/Attributes/note" value="Note" /> <_config:mapping xpath="Attributes/field1" value="Field1"/> <_config:mapping xpath="Attributes/field2" value="Field2"/> <_config:mapping xpath="" value="Delete" valueFrom="InputData" deleteValue="1"/> </_config:DataMapping>If you are performing an insert or replace operation, do not specify the "Delete" column in the CSV file or you can leave the "Delete" column empty.
Business object mediator
The mediator class name is CatalogGroupMediator.