Tutorials > Management Center > Add new fields in the Catalogs tool > Customize the Catalogs tool to upload data from custom tables
Create custom versions of the configuration files
In this step of the tutorial, you create custom versions of the data load order and business object configuration files.
By default, the Catalog Upload feature provides various catalog business object configuration files. The configuration files defines the mapping from the comma-separated value (CSV) columns to the Xpath express of the logical business object.
To map the warranty and care instruction data to CSV columns, you create custom version of the catalog entry business object configuration file.
Catalog Upload uses the configuration files in the following directories:
- workspace_dir\WC\xml\config\com.ibm.commerce.catalog\dataload.
Do not modify the contents of this directory.
- workspace_dir\WC\xml\config\com.ibm.commerce.catalog-ext\dataload.
- Use for customized configuration files.
Before loading catalog data, the Catalog Upload feature merges configuration files from both directories.
Procedure
- Create a custom version of the catalog entry business object configuration file.
The Catalog Upload feature catalog entry business object configuration is wc-loader-catalog-entry.xml. You will create a version of the custom business object configuration file from the existing wc-loader-catalog-entry.xml file.
- Create the workspace_dir\WC\xml\config\com.ibm.commerce.catalog-ext\dataload directory if it does not already exist.
- Copy the workspace_dir\WC\xml\config\com.ibm.commerce.catalog\dataload\wc-loader-catalog-entry.xml file into the workspace_dir\WC\xml\config\com.ibm.commerce.catalog-ext\dataload directory.
- Rename the file to wc-loader-catalog-entry-with-warranty.xml.
- Open the workspace_dir\WC\xml\config\com.ibm.commerce.catalog-ext\dataload\wc-loader-catalog-entry-with-warranty.xml file and examine its contents.
In the wc-loader-catalog-entry-with-warranty.xml file: 1. The attribute value in the <_config:DataReader> element specifies the CSV data reader. You do not need to change this value since the input file is in CSV format. 2. The attribute value in the <_config:BusinessObjectBuilder> element specifies the base business object builder. 3. The attribute value in the <_config:BusinessObjectMediator> element specifies the business object mediator class. The catalog entry mediator supports loading custom catalog entry UserData. You do not need to change this value is the catalog entry mediator because the warranty and care instruction data are extension of the CatalogEntry business object.
- Map the warranty and care instruction data to CSV column definition. Add the following snippet inside the <_config:DataMapping> element.
<_config:mapping xpath="UserData/UserDataField/warterm" value="WarrantyTerm" /> <_config:mapping xpath="UserData/UserDataField/wartype" value="WarrantyType" /> <_config:mapping xpath="Description/Attributes/careinstruction" value="CareInstruction" />
The WarrantyTerm, WarrantyType, and CareInstruction are used as CSV column headers when loading a catalog entry.
- Save and close the file.
- Create a custom version of the data load order configuration file.
The Catalog Upload feature data load order configuration file is wc-dataload.xml. You will create a custom version of the data load order configuration file in the customization directory.
To ensure that the Catalog Upload feature picks up the data load order customization, make sure the custom version of the data load order file is also named wc-dataload.xml.
- Create a wc-dataload.xml file in the workspace_dir\WC\xml\config\com.ibm.commerce.catalog-ext\dataload directory.
- Copy the following content into the wc-dataload.xml file
<?xml version="1.0" encoding="UTF-8"?> <_config:DataLoadConfiguration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.ibm.com/xmlns/prod/commerce/foundation/config ../xsd/wc-dataload.xsd" xmlns:_config="http://www.ibm.com/xmlns/prod/commerce/foundation/config"> <_config:LoadOrder> <_config:LoadItem name="CatalogEntry" loadSequence="3.0" businessObjectConfigFile="wc-loader-catalog-entry-with-warranty.xml"> <_config:DataSourceLocation location="${CatalogEntry}" /> </_config:LoadItem> </_config:LoadOrder> </_config:DataLoadConfiguration>
Your custom wc-dataload.xml file is merged with the default Catalog Upload feature wc-dataload.xml file, so you include the custom configurations only. The following is the content of the custom wc-dataload.xml file:
In the wc-dataload.xml file: The name attribute value uses the same load item name as the catalog entry business object. This load item overrides the load item with the same name provided in the default wc-dataload.xml. The loadSequence attribute value specifies the load sequence. If you are loading multiple CSV files in a compressed file, it is the load sequence for all the CSV files. A smaller load sequence gets loaded first. The businessObjectConfigFile attribute value points to the business configuration file you created. The location attribute value is defined by a variable substitution. This variable name is the same as the load item name attribute value.
- Save and close the file.
- (Optional) Package and deploy the custom version of the wc-dataload.xml file and wc-loader-catalog-entry-with-warranty.xml file by following the steps in Package Java EE assets for a partial application and Deploy J2EE assets for a partial application.