Example: Categories

You can insert, replace, or delete your category data simultaneously by using the Data Load utility. These examples uses a CSV file to demonstrate how to insert, replace, or delete your categories data.

This example uses a CSV file to demonstrate how to insert, replace, or delete your data. You can also create and use an XML formatted file to insert, replace, or delete your data. If you choose to create and use an XML formatted file, ensure that your XML elements use the same names as are used for CSV column names.

CSV column and XML element definitions

GroupIdentifier
Required: (String) The category identifier. This field cannot be null, and it must be unique.
TopGroup
(Boolean) Indicates whether this column is a top-level category or a subcategory. Top categories do not have parent categories. Set the column value to be true for a top category. Set the column value to be false or null for a subcategory. The default value is false. Any value other than true automatically defaults to false.
ParentGroupIdentifier
(String) The parent identifier of this category. Leave empty for top-level category.
Sequence
(Double) An optional number that is 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 that is used for searching. Enclose multiple keywords in double quotation marks that are separated by commas, for example "keyword 1, keyword 2, keyword3".
Delete
(String) A flag that indicates whether to delete. Specify 1 to delete the row.

You can use the mark for delete option when you are deleting a category. When you configure the Data Load utility to use this behavior, categories are not deleted from the database when you set a category to delete in an input file. When you set the Delete column for a category to '1', the category is marked for deletion. The utility updates the value for the MARKFORDELETE column of the object row in the CATGROUP table instead of deleting the row.

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 that is different from the store that is 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 in an extended sites store, when the parent store is different from the store that your category is 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.

Insert or replace - CSV file with sample category data

The 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 Appliances 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

Delete - CSV file with sample category data

To delete a category, add a Delete column to your 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 have the associated category deleted. Rows that do not have anything in the Delete column have the associated categories inserted or replaced, depending on whether previous 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

Mapping 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 perform 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 com.ibm.commerce.catalog.dataload.mediator.CatalogGroupMediator.
Note: This mediator does not support marking a category for delete. If you define a mapping to update the MARKFORDELETE column for category and set a category to be marked for delete in an input file, the Data Load utility explicitly deletes the category. The operation also deletes any related records in table CATTOGRP, CATGRPREL, CATGPENREL tables for the category.
The CatalogGroupMediator mediator supports marking a category for delete through a configurable property. To enable this property, add the following configuration in the <_config:BusinessObjectMediator> element of the business object configuration file:
<_config:BusinessObjectMediator className="com.ibm.commerce.catalog.dataload.mediator.CatalogGroupMediator" componentId="com.ibm.commerce.catalog">
     <_config:property name="markForDelete" value="true" />
</_config:BusinessObjectMediator>
  • If you also configure the Data Load utility to load SEO information, any relevant SEO information for the category is removed when you set the category to be marked for delete.
  • If your store uses WebSphere Commerce search, the search index rebuilds to remove categories that are marked for delete and to remove the relationships for these categories.
Note: When you use a mediator that is provided with WebSphere Commerce with the Data Load utility, the utility assumes that you are loading data for all columns for a business object. If you want to update the data in only specific columns, configure a column exclusion list for the load process. A column exclusion list causes the Data Load utility to ignore specific columns during the load operation. If you do not use a column exclusion list, the utility updates all columns in the row of a database table row when the utility updates the row. If no value is set in the input file, the utility can replace the existing column value with a default value or set the value to be null. For more information, see Configuring a column exclusion list.