Samples > Data load utility samples > Examples: Mapping data > Examples: Mapping pricing data


Example: Deleting price lists

The data load utility provides two modes for deleting price lists defined in CSV 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 CSV file is equal to the "deleteValue" defined in <_config_Mapping> element in the data load configuration file then the delete action is performed. You can delete multiple price lists at the same time. You can also insert price lists, replace price lists, and delete price lists at the same time.


CSV file with sample price list data to be deleted

To delete a price list, add a delete column to the 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 depends on the firstLineIsHeader attribute in the price list data load configuration file. The firstLineIsHeader is an attribute of <_config:DataReader> element.

firstLineIsHeader

true

Indicates that the first line in the CSV file is treated as column name data, and it is not inserted into the database.

false

Indicates that the first line in the CSV file is data to be read and inserted into the database.

Formatted CSV file with column headings
Name Description Precedence Type Delete
Standard Price List This is the standard price list. 1 S -
Holiday price list This is the price list for the holiday. 5 C y
Legacy system price list This is the price list managed by the legacy system. 2 E -
Overstock price list This is 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. The error shows ID was not resolved. The price list unique ID cannot be resolved when using the price list name and the unique ID is the primary key to determine a price list.

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


CSV file column definitions

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

uniqueID

(Optional, String) The identifier of the price list. If both the price list name and price list uniqueID are provided in the CSV record, the data load utility loads according to price list uniqueID. When there is a data mapping for price list UniqueID in the price list data load configuration file, then the uniqueID is mandatory in the CSV file.

Name

(Mandatory, String) The name of the price list. If both the price list name and price list uniqueID are provided in CSV record, the data load utility loads according to price list uniqueID.

Description

(Optional, String) The description of this price list.

Precedence

(Optional, Double) When more than one trading position container is qualified, the system uses the trading position container with the highest precedence. If this column is null from the input file, then it is set to the default value of 0.0.

Type

(Optional, String) The Trading Position Container type:

S

(Default value) Standard price list which contains the base prices for the products in the store catalog.

C

Custom price list which specifies the list of products and their customized prices.

E

External price list.
Values other than S, C, or E are considered custom types. The type is inserted into the table. The mediator does not restrict this value.

Delete

(Optional, String) Indicates whether to delete this price list. The deleteValue, y in this example, is the string indicating that to delete that price list.


Map data

The following snippet maps each column of data in the source CSV file to a value.

    <_config:Data>         <_config:column number="1" name="Name" />         <_config:column number="2" name="Description" />         <_config:column number="3" name="Precedence" />         <_config:column number="4" name="Type" />         <_config:column number="5" name="Delete" />     </_config:Data>

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.

<_config:DataMapping>     <_config:mapping xpath="PriceListIdentifier/ExternalIdentifier/Name" value="Name" valueFrom="InputData" />     <_config:mapping xpath="Description/value" value="Description" valueFrom="InputData" />     <_config:mapping xpath="precedence" value="Precedence" valueFrom="InputData" />     <_config:mapping xpath="type" value="Type" valueFrom="InputData" />     <_config:mapping xpath="" value="Delete" valueFrom="InputData" deleteValue="y" />
</_config:DataMapping>

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.

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

<_config:BusinessObjectMediator className="com.ibm.commerce.price.dataload.mediator.PriceListMediator"> 
<_config:property name="markPriceListForDelete" value="false" /> 
</_config:BusinessObjectMediator> 

markPriceListForDelete

true

The price list is marked for delete.

To delete the records use the Database Cleanup utility.

false

The price list is deleted from the database. All related records are cascade deleted.


+

Search Tips   |   Advanced Search