Example: Deleting price lists

The Data Load utility provides two modes for deleting price lists defined in a load file: delete and replace. Use the delete mode to delete price lists if the mode is set to "Delete" in the data load configuration file. Use the replace mode to delete price lists if the mode is set to "Replace" in the data load configuration file.

In replace mode, if the value of the "Delete" column in the load file is equal to the "deleteValue" defined in <_config_Mapping> element in the data load configuration file then the delete action is performed. We can delete multiple price lists at the same time. We can also insert price lists, replace price lists, and delete price lists at the same time.

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.

Note: Do not delete the default price list for a store. If you do delete the default price list, the CATGRPTPC and STORETPC database tables must be updated with a new default price list for the store. Update these tables with the tradeposcn_ID of the new default price list. If a default price list is not set for the store, errors associated with the content in these tables can occur in Management Center and the storefront.


CSV file with sample price list data to be deleted

To delete a price list, add a delete column to your CSV file. In this example, the CSV file contains sample price list data. Some price lists are deleted, and others are inserted or replaced. The action depends on the state of the delete flag.

PriceListGroupDelete.csv 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.

Formatted CSV file with column headings
Name Description Precedence Type Delete
Standard Price List The standard price list. 1 S -
Holiday price list The price list for the holiday. 5 C y
Legacy system price list The price list that is managed by the legacy system. 2 E -
Overstock price list The price list for overstocked items. 1 C y

Behavior

  1. Delete price list with price list unique ID

    No exception is thrown in this scenario.

  2. Delete price list with price list name

    An exception is thrown if the price list does not exist in database and the error message, ID was not resolved, is displayed. The price list unique ID cannot be resolved when the price list name and unique ID are the primary key that identifies a price list.

    If the price list exists in the database, the price list is deleted successfully.


CSV column and XML element definitions

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


Mapping data

The following snippet maps 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 name of the column used in the <_config:DataMapping> element.

The following snippet maps 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.PriceRuleMediator. The corresponding logical schema is PriceRule.xsd. The component Id is com.ibm.commerce.price.

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 price list data load configuration file. The configuration is to set whether the Data Load utility marks a price list for deletion, or deletes the list from the database.