Example: Inserting and replacing non-ATP inventory

You can insert and replace non-ATP inventory by using the Data Load utility. This example uses a CSV file to demonstrate how to insert and replace your inventory information.

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.

Prerequisites

  • Make sure that the inventory system is non-ATP, that is, check STORE table to make sure INVENTORYSYSTEM=-2
  • The corresponding data of catalog entry existed in the table CATENTRY of the database.
CSV file with sample data
In this example, the data source is a CSV file named nonATPinventory.csv. The file contains sample data. CSV file with sample data
PartNumber Quantity QuantityUnit CatEntryStoreIdentifier
A0000101 1000 C62 10701
A0000106 300 C62
A0000107

CSV column and XML element definitions

PartNumber
(String) The part number of this item. It uniquely identifies an item for a particular owner. Together with the owner identifier, it is used to retrieve the primary key of CATENTRY table, that is, CATENTRY_ID. This field is required and cannot be null if the CatalogEntryUniqueId field is not specified in CSV file.
Quantity
(Integer) The quantity amount, in units that are indicated by QUANTITYUNIT. Zero is used if it is not provided in the CSV.
QuantityUnit
(String) The unit of measurement for QUANTITY. "C62" is used if it is empty in the CSV.
CatEntryStoreIdentifier
(String)This field is used in an extended sites store. If the CatalogEntry is defined in a catalog entry asset store, this field stands for the identifier of the catalog entry asset store. This identifier is used to retrieve the catalog entryOwner.
HCL Commerce EnterpriseThis field is required if you are using an extended sites store.

Other optional fields not included in the example are:

CurrentStoreIdentifier
(String) The identifier of the store that this item belongs to. This column can be added into CSV if the item belongs to a store that is different from the store that is defined in BusinessContext elements wc-dataload-env.xml. If this column is not provided in the CSV file, the StoreIdentifier in the business context is used.
FulfillmentCenterId
(Integer) The identifier of the fulfillment center that this item belongs to. This column can be added into CSV if the item belongs to a fulfillment center that is different from the one defined in BusinessContext property of wc-dataload-env.xml. If this column is not provided in the CSV file, the fulfillmentCenterIdentifier is retrieved by FulfillmentCenterName. If it is not found, the fulfillmentCenterIdentifier in the business context is used. If it is not specified in either CSV file or business context, the default fufillmentCenter of the specified store is used.
FulfillmentCenterName
(String) The name of the fulfillment center that this item belongs to. This column is used to retrieve fulfillmentCenterIdentifier.
OwnerId
(Long) The identifier of the catalog entryOwner of this item. If it is not specified in the CSV file, the owner of the catalog entry asset store is retrieved. If it is not found, the owner of current store is retrieved. If it is not found either, the ownerId specified in BusinessContext property of wc-dataload-env.xml is used.
CatalogEntryUniqueId
(Long) The identifier of the catalog entry of this item. If this field is not specified in CSV file, the identifier of catalog entry is retrieved by part number and owner of the catalog entry.
Delete
(String) Indicates whether to delete this record. This field takes effect when dataLoadMode is "replace". If the value of this field equals to deleteValue, the corresponding record is deleted. The default deleteValue is 1 and the deleteValue can be configured under <DataMapping> element in BusinessObjectConfigFile.
Business context data
The following code snippet from the wc-dataload-env.xml configuration file provides the business context data necessary for loading the data:
<_config:BusinessContext storeIdentifier="AuroraESite">
<_config:property name="fulfillmentCenterName" value="Aurora Home"/>
<_config:property name="ownerId" value="7000000000000000002"/>
</_config:BusinessContext>
storeIdentifier
(String) The identifier of the store that this item belongs to. It is used if CSV file does not provide this information. The StoreIdentifier is used to retrieve the storeID and the ownerID.
fulfillmentCenterId
(String) The identifier of the fulfillment center this item belongs to. It is used if the identifier cannot be retrieved by FulfillmentCenterId or FulfillmentCenterName specified in CSV file.
FulfillmentCenterName
(String) The name of the fulfillment center this item belongs to. It is used to retrieve the fulfillmentCenterID, if fulfillmentCenterID is not retrieved from CSV file or defined in business context.
OwnerId
(Long) The identifier of the catalog entryOwner of this item. It is used if the catalog entryOwner is not provided in CSV file and cannot be retrieved by specified store identifier.

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:DataReader className="com.ibm.commerce.foundation.dataload.datareader.CSVReader" firstLineIsHeader="true">
	<_config:Data>
		<_config:column number="1" name="PartNumber" />
		<_config:column number="2" name="Quantity" />
		<_config:column number="3" name="QuantityUnit" />
		<_config:column number="4" name="CatEntryStoreIdentifier" />
	</_config:Data>
</_config:DataReader >

The following snippet from the sample configuration file demonstrates how to map each column of the data in the CSV file to a business object logical schema path. The attribute 'value' represents the name of a column of the CSV file, which is defined in the configuration snippet above. Each column in the CSV file must have a mapping to the logical schema path. If the optional fields specified above are present in the CSV file, the mapping for them must be added. The mapping logical schema path is specified in the following table.

<_config:DataMapping>
        <_config:mapping xpath="InventoryAvailabilityIdentifier/ExternalIdentifier/CatalogEntryIdentifier/ExternalIdentifier/PartNumber" value="PartNumber" valueFrom="InputData" />
        <_config:mapping xpath="FulfillmentCenterInventoryAvailability[0]/AvailableQuantity/value" value="Quantity" valueFrom="InputData" />
        <_config:mapping xpath="FulfillmentCenterInventoryAvailability[0]/AvailableQuantity/uom" value="QuantityUnit" valueFrom="InputData" />
        <_config:mapping xpath="InventoryAvailabilityIdentifier/ExternalIdentifier/CatalogEntryIdentifier/ExternalIdentifier/StoreIdentifier/ExternalIdentifier/NameIdentifier" value="CatEntryStoreIdentifier" />
</_config:DataMapping>

Business object mediator

The mediator class name is com.ibm.commerce.catalog.dataload.mediator.CatalogEntryMediator.

Note: When you use a mediator that is provided with HCL Commerce with the Data Load utility, the utility assumes that you are loading data for all columns for a business object. If you want 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. For more information, see Configuring a column exclusion list.