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 you are adding an offer that previously did not exist in the database. Or use the replace mode when you 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. You 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.
- Insert mode
-
- Identifier specified: The insert fails if an offer with the same combination exists in the database.
- Identifier not specified: Offer is inserted successfully.
- Replace mode
-
- Identifier specified: Updates the specified offer according to the Identifier. The offer is inserted if an offer with the identifier does not exist in the database.
- Identifier not specified: Each input line in the
CSV file is resolved to a pair of values:
(CATENTRY_ID, TRADEPOSCN_ID). The mediator checks the OFFER table
for the number of records with the same pair value.
- The existing offer is updated directly, if the number of records with the same pair in the database is one.
- All the existing offers are deleted and new offers are inserted from the CSV file if the number of records with the same pair in the database is greater than one.
CSV file with sample offer data for a single currency
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.
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.
- 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 you are loading an offer, the price list name or price list UniqueID is optional. When both of them are not provided in the CSV file, the store's default price list name is used to load. If one of them is provided, the provided price list is used to load. If both of them are provided in CSV file, the price list uniqueID is used to load.
- 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 load.
- CatentryPartNumber
- (Required, String) The part number of the catalog entry that this offer is defined for. When you are loading an offer, the CatentryPartNumber name or CatentryUniqueID is required. When both of them are not provided in CSV file, the offer fails to load. If any of them is provided, the provided catentry is used to load. If both of them are provided in CSV file, the CatentryUniqueID is used to load.
- 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, it sets a default value of "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
- (Optional, Decimal) The price of the offer in the wanted currency.
- Currency
- (Optional, String) The currency that is specified for the offer price.
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.
<_config:DataSource>
<_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="Price" />
<_config:column number="15" name="Currency" />
</_config:Data>
</_config:DataSource>
The number
attribute in the <_config:column>
element,
defines the column order in the CSV record file. The name
attribute defines the
column name that is used in the <_config:DataMapping>
element.
<_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="Start Date" valueFrom="InputData" />
<_config:mapping xpath="PriceEntry[0]/EndDate" value="End Date" valueFrom="InputData" />
<_config:mapping xpath="PriceEntry[0]/QuantityUnit" value="QuantityUnitIdentifier"
valueFrom="InputData" />
<_config:mapping xpath="PriceEntry[0]/MaximumQuantity" value="MaximumQuantity"
valueFrom="InputData" />
<_config:mapping xpath="PriceEntry[0]/MinimumQuantity" value="MinimumQuantity"
valueFrom="InputData" />
<_config:mapping xpath="PriceEntry[0]/LastUpdate" value="LASTUPDATE" valueFrom="InputData" />
<_config:mapping xpath="PriceEntry[0]/Description/Value" value="Description"
valueFrom="InputData" />
<_config:mapping xpath="PriceEntry[0]/Price/Value" value="Price" valueFrom="InputData" />
<_config:mapping xpath="PriceEntry[0]/Price/Currency" value="Currency" valueFrom="InputData" />
</_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
.