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
- Replace mode
- Identifier specified: Only deletes the specified offer according to the Identifier when delete flag is set. If the offer with the Identifier does not exist in the database, no offer is deleted.
- Identifier not specified: Deletes all offers with same pair in the database when delete flag is set.
- Delete mode
- It ignores the delete flag and always delete offers when:
- Identifier specified: Only deletes the specified offer according to the Identifier. If the offer with the Identifier does not exist in the database, no offer is deleted.
- Identifier not specified: Deletes all offers with same pair in the database.
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.
Standard Price List,1000573,1100456,3,2009-03-15 15:47,2009-05-15 15:47,each,10,0,2009-03-16 15:47:00.0, Elegant wine glass,4.50,10.05,30.75,3.48,442.56,6074.84,152.42,y Holiday price list,1000574,1100457,5,2009-12-15 15:47:00.0,2009-12-31 15:47:00.0,each,5,0,2009-11-28 15:47:00.0, Decorative bed cover,25,55.84,170.84,19.31,2,458.61,33691.25,846.71 Legacy system price list,1000575,1100458,2,2009-02-15 15:47:00.0,2009-06-02 15:47:00.0,each,10,0,2009-02-22 15:47:00.0, Old Cologne,9.99,22.31,68.27,7.72,982.46,13,463.02,338.35 Overstock price list,1000576,1100459,3,2009-03-15 15:47:00.0,2009-03-31 15:47:00.0,each,10,0,2009-03-16 15:47:00.0, Candle holder,3,6.70,20.50,2.32,295.03,4042.95,101.61,yThe 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.
- 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.
Behavior
- 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.
- 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.
- PriceListUniqueID
- (Optional, String) The identifier of the price list. When there is a data mapping for price list UniqueID in the price list data load configuration file, then the uniqueID is required in the CSV file.
- PriceListName
- (Optional, String) The name of the price list that contains this offer. When deleting offer, price list name or price list UniqueID is optional. When both of them are not provided in CSV file, the default price list of the store is used to delete. If any of them is provided, the provided price list is used to delete. If both of them are provided in CSV file, the price list uniqueID is used to delete.
- CatentryUniqueID
- (Optional, String) The unique identifier for the related catentry. When there is a data mapping in the offer data load configuration file; then the CatentryUniqueID is required. If both of them are provided in CSV file, the CatentryUniqueID is used to delete.
- CatentryPartNumber
- (Optional, String) The part number of the catalog entry that this offer defined for. When deleting offer, the CatentryPartNumber name or CatentryUniqueID is required. When both of them are not provided in CSV file, the delete offer fails. If any of them is provided, the provided catentry is used to delete. If both of them are provided in CSV file, the CatentryUniqueID is used to delete.
- Identifier
(Optional, Double) The number that uniquely identifies the offer when the value for the column is combined with unique catalog entry ID and price list ID values for the offer. Maps to the OFFER.IDENTIFIER database column.
- Precedence
- (Optional, Double) When more than one Offer is effective at a particular time, the one with the highest precedence is used. If not specified in the input file, the value is set to "0.0".
- StartDate
- (Optional, Timestamp) The start of the time range during which this offer is effective. Use the format yyyy-mm-dd hh:mm:ss.millis.
- EndDate
- (Optional, Timestamp) The end of the time range during which this offer is effective. Use the format yyyy-mm-dd hh:mm:ss.millis.
- QuantityUnitIdentifier
- (Optional, String) The unit of measure for Minimum Quantity and Maximum Quantity.
- MaximumQuantity
- (Optional, Double) The maximum quantity that can be purchased in a single order under this offer.
- MinimumQuantity
- (Optional, Double) The minimum quantity that can be purchased in a single order under this offer.
- LastUpdate
- (Optional, Timestamp) The last time that the offer is updated. Use the format yyyy-mm-dd hh:mm:ss.millis.
- Description
- (Optional, String) The description for this offer.
- Price In USD
- (Optional, Decimal) The price in US Dollars.
- Price In BRL
- (Optional, Decimal) The price in Brazilian Reais.
- Price In CNY
- (Optional, Decimal) The price in Chinese Yuan Renminbi.
- Price In EUR
- (Optional, Decimal) The price in Euros.
- Price In JPY
- (Optional, Decimal) The price in Japanese Yen.
- Price In KRW
- (Optional, Decimal) The price in (South) Korean Won.
- Price In TWD
- (Optional, Decimal) The price in Taiwanese New Dollars.
- Delete
- (Optional, String) Indicates whether to delete this multiple-currency offer. The deleteValue is the string to use in the CSV file to indicate to delete that offer. In this example, we use the string 'y'.
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.
<_config:Data> <_config:column number="1" name="PriceListUniqueId" /> <_config:column number="2" name="PriceListName" /> <_config:column number="3" name="CatentryUniqueId" /> <_config:column number="4" name="CatentryPartNumber" /> <_config:column number="5" name="Identifier" /> <_config:column number="6" name="Precedence" /> <_config:column number="7" name="StartDate" /> <_config:column number="8" name="EndDate" /> <_config:column number="9" name="QuantityUnitIdentifier" /> <_config:column number="10" name="MinimumQuantity" /> <_config:column number="11" name="MaximumQuantity" /> <_config:column number="12" name="LastUpdate" /> <_config:column number="13" name="Description" /> <_config:column number="14" name="PriceInUSD" /> <_config:column number="15" name="PriceInBRL" /> <_config:column number="16" name="PriceInCAD" /> <_config:column number="17" name="PriceInCNY" /> <_config:column number="18" name="PriceInEUR" /> <_config:column number="19" name="PriceInJPY" /> <_config:column number="20" name="PriceInKRW" /> <_config:column number="21" name="PriceInTWD" /> <_config:column number="22" 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 from the sample configuration file demonstrates how to map each value to a business object logical schema path.
<_config:DataMapping> <_config:mapping xpath="PriceListIdentifier/UniqueID" value="PriceListUniqueId" valueFrom="InputData" /> <_config:mapping xpath="PriceListIdentifier/ExternalIdentifier/Name" value="PriceListName" valueFrom="InputData" /> <_config:mapping xpath="PriceEntry[0]/CatalogEntryIdentifier/UniqueID" value="CatentryUniqueId" valueFrom="InputData" /> <_config:mapping xpath="PriceEntry[0]/CatalogEntryIdentifier/ExternalIdentifier/PartNumber" value="CatentryPartNumber" valueFrom="InputData" /> <_config:mapping xpath="PriceEntry[0]/Qualifier" value="Identifier" valueFrom="InputData" /> <_config:mapping xpath="PriceEntry[0]/precedence" value="Precedence" valueFrom="InputData" /> <_config:mapping xpath="PriceEntry[0]/startDate" value="StartDate" valueFrom="InputData" /> <_config:mapping xpath="PriceEntry[0]/endDate" value="EndDate" valueFrom="InputData" /> <_config:mapping xpath="PriceEntry[0]/lastUpdate" value="LastUpdate" valueFrom="InputData" /> <_config:mapping xpath="PriceEntry[0]/quantityUnit" value="QuantityUnitIdentifier" valueFrom="InputData" /> <_config:mapping xpath="PriceEntry[0]/minimumQuantity" value="MinimumQuantity" valueFrom="InputData" /> <_config:mapping xpath="PriceEntry[0]/maximumQuantity" value="MaximumQuantity" valueFrom="InputData" /> <_config:mapping xpath="PriceEntry[0]/Description/value" value="Description" valueFrom="InputData" /> <_config:mapping xpath="PriceEntry[0]/Price/Price/currency" value="USD" valueFrom="Fixed" /> <_config:mapping xpath="PriceEntry[0]/Price/Price/value" value="PriceInUSD" valueFrom="InputData" /> <_config:mapping xpath="PriceEntry[0]/Price/AlternativeCurrencyPrice[0]/currency" value="BRL" valueFrom="Fixed" /> <_config:mapping xpath="PriceEntry[0]/Price/AlternativeCurrencyPrice[0]/value" value="PriceInBRL" valueFrom="InputData" /> <_config:mapping xpath="PriceEntry[0]/Price/AlternativeCurrencyPrice[1]/currency" value="CAD" valueFrom="Fixed" /> <_config:mapping xpath="PriceEntry[0]/Price/AlternativeCurrencyPrice[1]/value" value="PriceInCAD" valueFrom="InputData" /> <_config:mapping xpath="PriceEntry[0]/Price/AlternativeCurrencyPrice[2]/currency" value="CNY" valueFrom="Fixed" /> <_config:mapping xpath="PriceEntry[0]/Price/AlternativeCurrencyPrice[2]/value" value="PriceInCNY" valueFrom="InputData" /> <_config:mapping xpath="PriceEntry[0]/Price/AlternativeCurrencyPrice[3]/currency" value="EUR" valueFrom="Fixed" /> <_config:mapping xpath="PriceEntry[0]/Price/AlternativeCurrencyPrice[3]/value" value="PriceInEUR" valueFrom="InputData" /> <_config:mapping xpath="PriceEntry[0]/Price/AlternativeCurrencyPrice[4]/currency" value="JPY" valueFrom="Fixed" /> <_config:mapping xpath="PriceEntry[0]/Price/AlternativeCurrencyPrice[4]/value" value="PriceInJPY" valueFrom="InputData" /> <_config:mapping xpath="PriceEntry[0]/Price/AlternativeCurrencyPrice[5]/currency" value="KRW" valueFrom="Fixed" /> <_config:mapping xpath="PriceEntry[0]/Price/AlternativeCurrencyPrice[5]/value" value="PriceInKRW" valueFrom="InputData" /> <_config:mapping xpath="PriceEntry[0]/Price/AlternativeCurrencyPrice[6]/currency" value="TWD" valueFrom="Fixed" /> <_config:mapping xpath="PriceEntry[0]/Price/AlternativeCurrencyPrice[6]/value" value="PriceInTWD" 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.
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.
<_config:BusinessObjectMediator className="com.ibm.commerce.price. dataload.mediator.OfferMediator"> <_config:property name="markOfferForDelete" value="true" /> </_config:BusinessObjectMediator>
- markOfferForDelete
- true
- The offer is marked for delete. To delete the records, use the Database Cleanup utility.
- false
- The offer is deleted from the database. All related records are cascade deleted.