Example: Inserting and replacing offers with a single currency

The Data Load utility provides two modes for loading single-currency offers. Use the insert mode when we are adding an offer that previously did not exist in the database. Or use the replace mode when we are replacing an existing offer with a different offer. The behavior of each mode depends on whether the identifier is specified.

This example uses a CSV file to demonstrate how to insert, replace, or delete your data. We 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 file with sample offer data for a single currency

The first row in the CSV file can also be column names, which depend on the firstLineIsHeader attribute in the price list data load configuration file. The firstLineIsHeader is an attribute of <_config:DataReader> element.

In this example, the data source is a CSV file named SingleCurrencyOfferGroup.csv. The file contains sample offer data. Each column is delimited by a comma. Example of SingleCurrencyOfferGroup.csv file


CSV column and XML element definitions

The column order is defined in the offer data load configuration file. See the number attribute in the <_config:Data> element.


Mapping data

The following snippet from the sample configuration file demonstrates how to map each column of data in the source CSV file to a value.

The number attribute in the <_config:column> element, defines the column order in the CSV record file. The name attribute defines the column name used in the <_config:DataMapping> element. The following snippet from the sample configuration file demonstrates how to map each value to a business object logical schema path.

The value attribute in the <_config:DataMapping> element must be consistent with the name attribute of the corresponding item in the <_config:column> element. Both attributes are case-sensitive.


Business object mediator

The mediator class name is com.ibm.commerce.price.dataload.mediator.OfferMediator.

Note: When we use a mediator that is provided with WebSphere Commerce with the Data Load utility, the utility assumes that we are loading data for all columns for a business object. 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. See Configure a column exclusion list.