Example: Deleting offers with multiple currencies

The Data Load utility provides two modes for deleting offers with multiple currencies defined in a load file from database: delete and replace. Use the delete mode to delete offers if the mode is set to "Delete" in the data load configuration file. Use the replace mode to delete offers if the mode is set to "Replace" in the data load configuration file. 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 to be deleted

To delete an offer, add a delete column to your CSV file. The file contains sample offer data. Some offers are deleted, and others are inserted or replaced, depending on the state of the delete flag. Each column is delimited by a comma. The following sample shows the unformatted CSV file:

Note: The following sample is separated into multiple lines for readability. If you use this sample we can include this as a single unformatted line in your file.

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.

Behavior

  1. Delete offer with price list name and catentry part number

    No exception is thrown if the offer does not exist in database in this scenario. The price list and catentry specified are not related to any offers. No offers are deleted.

    If the offer exists in the database, the offer is deleted successfully.

  2. Delete offer with price list unique ID and catalog entry unique ID.

    No exception is thrown in this scenario.


CSV column and XML element definitions

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


Mapping data

This code snippet from the sample configuration file, demonstrates how to map each column of data in the source CSV file to a value. It also shows how to indicate which columns to delete.

The number attribute in the <_config:column> element, defines the column order in the CSV record file. The name attribute defines the name of the column 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.

The following example shows how to configure the BusinessObjectMediator in the offer data load configuration file to mark an offer for deletion, or to delete it from the database.