Example: Inserting and deleting catalog filter catalog entry selections

You can insert or delete catalog entry information for a catalog filter. In the CSV file, the required information is the catalog filter name, store identifier, catalog identifer, selection type (Exclude or Include), and catalog entry part number. The catalog entry can be inserted or deleted, it cannot be replaced. For example, you cannot change an included catalog entry to exclude.

This example uses a CSV file to demonstrate how to insert or delete your data. You can also create and use an XML formatted file instead of a CSV file. If you choose to create an use an XML file, ensure that your XML elements use the same names as are used for CSV column names.

Prerequisites

  • Ensure that the store exists.
  • Ensure that the catalog data exists.
  • Ensure that the catalog filter is loaded.

CSV file with sample catalog filter catalog entry selection data

CatalogFilterCatentry.csv file

The file contains catalog filter catalog entry selection data. Each column is delimited by a comma.

Table 1. CatalogFilterCatentry
CatalogFilterId CatalogFilterName StoreIdentifier CatalogIdentifier SelectionType PartNumber Delete
1000001 CatalogFilterA AuroraESite AuroraESite Include FULO-0301 0
1000001 CatalogFilterA AuroraESite AuroraESite Include FULO-0401 0
1000001 CatalogFilterA AuroraESite AuroraESite Exclude FUOF-0101 0
1000001 CatalogFilterA AuroraESite AuroraESite Exclude FUOF-0301 0

CSV column and XML element definitions

CatalogFilterName
Required, String: The name of the catalog filter. Ensure that the combination of CatalogIdentifier, StoreIdentifier, and CatalogFilterName are unique.
StoreIdentifier
Required, String: The identifier of the store that the catalog filter belongs to.
CatalogIdentifier
Required, String: The identifier of the catalog that the catalog filter belongs to.
SelectionType
Required, String: The type of the catalog entry selection: Include, Exclude.
PartNumber
Required, String: The catalog entry part number to include or exclude in the catalog filter.
Delete
Optional, 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, deleteValue might be configured under DataMapping element in BusinessObjectConfigFile.
Other optional fields not included in the example are:
CatalogFilterId
Optional, String: The reference number of the catalog filter. If the reference number is provided in the CSV, then it is used. If this field is provided, then the CatalogFilterName, CatalogFilterName, CatalogIdentifier is not needed.

Business context data

The following code snippet from the wc-dataload-env.xml configuration file provides the required business context data:

<_config:BusinessContext storeIdentifier="AuroraESite" catalogIdentifier="AuroraESite">
</_config:BusinessContext>
storeIdentifier
String: The store identifier, for example "AuroraESite". This parameter is used when the storeIdentifier is not provided in the CSV file. If the storeIdentifier is provided in the CSV file, it is used. The storeIdentifier is used to retrieve the storeID and the ownerID.
catalogIdentifier
String: The catalog identifier, for example "AuroraESite". This parameter is used when the catalog identifier is not provided in the CSV file. If the catalogIdentifier is provided in the CSV file, it is used.

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" 
   useHeaderAsColumnName="true" /> 

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="CatalogFilterIdentifier/UniqueID" value="CatalogFilterId" />      
  <_config:mapping xpath="CatalogFilterIdentifier/ExternalIdentifier/Identifier" value="CatalogFilterName" />
  <_config:mapping xpath="CatalogFilterIdentifier/ExternalIdentifier/StoreIdentifier/ExternalIdentifier/NameIdentifier" value="StoreIdentifier" />
  <_config:mapping xpath="CatalogFilterIdentifier/ExternalIdentifier/CatalogIdentifier/ExternalIdentifier/Identifier" value="CatalogIdentifier" />
  <_config:mapping xpath="ProductSetSelection/selection" value="SelectionType" />
  <_config:mapping xpath="ProductSetSelection/ProductSet/CatalogEntryIdentifier/ExternalIdentifier/PartNumber" value="PartNumber" />
  <_config:mapping xpath="" value="Delete"  deleteValue="1"/>
</_config:DataMapping>
Note: When you use a mediator that is provided with WebSphere 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.

Business object mediator

The mediator class name is com.ibm.commerce.catalogfilter.dataload.mediator.CatalogFilterCatentrySelectionMediator. The corresponding logical schema is CatalogFilter.xsd.