Example: Inserting and replacing catalog filter conditions

You can insert or replace your catalog filter conditions by using the Data Load utility. These examples use a CSV file to demonstrate how to insert or replace your catalog filter condition data.

Feature Pack 6 or laterThis 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

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

CSV file with sample catalog filter condition data

CatalogFilterCondition.csv. The file contains sample catalog filter condition data. Each column is delimited by a comma.

Sample data
CatalogFilterName StoreIdentifier CatalogIdentifier CatalogGroupIdentifier ConditionGroupIdentifier ConditionType AttributeName Operator AttributeValueIdentifier AttributeValue LanguageId ValueType
CatalogFilterA Madisons Madisons Lounge Chairs conditionLoungeChairAnd 0 Color not equals Red, Green, Black Red, Green, Black -1 String
CatalogFilterA Madisons Madisons Lounge Chairs conditionLoungeChairAnd 1 Manufacturer equals ABC ABCcompany -7 String

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.
CatalogGroupIdentifier
Required, String: The identifier of the catalog group to include or exclude in this catalog filter.
ConditionGroupIdentifier
The unique name of the condition.
ConditionType
Required, String: The condition type:
0
The attribute is stored in the attribute dictionary.
1
The attribute is not stored in the attribute dictionary.
AttributeName
Required, String: The attribute name. For an attribute stored in the attribute dictionary, it is the identifier of the attribute.
Operator
Required, String: The condition operator, which can be any of the following operators:
  • equals
  • not equals
  • less than
  • not less than
  • greater than
  • not greater than
AttributeValueIdentifier
Required when ConditionType is 0, String: The unique identifier of the attribute value. Used for attribute dictionary attributes. It can contain multiple values. Each value is delimited by a comma.
AttributeValue
Required, String: The values of the attribute, it can contain multiple values. Each value is delimited by a comma.
LanguageId
Required, Integer: The ID of the language.
  • -1 = English (US)
  • -2 = French
  • -3 = German
  • -4 = Italian
  • -5 = Spanish
  • -6 = Brazilian Portuguese
  • -7 = Simplified Chinese
  • -8 = Traditional Chinese
  • -9 = Korean
  • -10 = Japanese
  • -20 = Russian
  • -21 = Romanian
  • -22 = Polish
ValueType
Required. The type of the attribute value. For example, String or Integer.
Other optional fields not included in the example:
ConditionGroupId
Optional, String: The reference number of the condition group. If it is provided, then the CatalogFilterId, CatalogFilterName, StoreIdentifier, CatalogIdentifier, CatalogGroupIdentifier, ConditionGroupIdentifier are not needed.
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.
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. The deleteValue can be configured under the <DataMapping> element in the BusinessObjectConfigFile file.
CondField1
Optional, Long: Extension field for catalog filter condition (CFCOND.FIELD1). Delimit multiple values with a comma.
CondField2
Optional, Integer: Extension field for catalog filter condition (CFCOND.FIELD2), Delimit multiple values with a comma.
CondField3
Optional, String: Extension field for catalog filter condition (CFCOND.FIELD3), the maximum length is 254. Delimit multiple values with a comma.
CondField4
Optional, Float(20,5): Extension field for catalog filter condition (CFCOND.FIELD4). Delimit multiple values with a comma.
CondField5
Optional, Number: Extension field for catalog filter condition (CFCOND.FIELD5). Delimit multiple values with a comma.
CondValField1
Optional, Long: Extension field for catalog filter condition value (CFCONDVAL.FIELD1). Delimit multiple values with a comma.
CondValField2
Optional, Integer: Extension field for catalog filter condition value (CFCONDVAL.FIELD2). Delimit multiple values with a comma.
CondValField3
Optional, String: Extension field for catalog filter condition value (CFCONDVAL.FIELD3), the maximum length is 254. Delimit multiple values with a comma.
CondValField4
Optional, Float(20,5): Extension field for catalog filter condition value (CFCONDVAL.FIELD4). Delimit multiple values with a comma.
CondValField5
Optional, Number: Extension field for catalog filter condition value (CFCONDVAL.FIELD5). Delimit multiple values with a comma.

Business context data

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

<_config:BusinessContext storeIdentifier="Deprecated featureMadisons" catalogIdentifier="Madisons">
</_config:BusinessContext>
storeIdentifier
String: The store identifier, for example "Deprecated featureMadisons". 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 "Madisons". 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 preceding configuration snippet. Each column in the CSV file must have a mapping to the logical schema path. If the optional fields 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="CatalogGroupSelection/ConditionGroup/ConditionGroupIdentifier/UniqueID" value="ConditionGroupId" />
  <_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="CatalogGroupSelection/CatalogGroupSelectionIdentifier/ExternalIdentifier/CatalogGroupIdentifier/ExternalIdentifier/GroupIdentifier" value="CatalogGroupIdentifier" /> 
  <_config:mapping xpath="CatalogGroupSelection/ConditionGroup/ConditionGroupIdentifier/ExternalIdentifier/Identifier" value="ConditionGroupIdentifier" />
  <_config:mapping xpath="CatalogGroupSelection/ConditionGroup/Condition/conditionType" value="ConditionType" />
  <_config:mapping xpath="CatalogGroupSelection/ConditionGroup/Condition/ConditionAttributeIdentifier/ExternalIdentifier/Identifier" value="AttributeName" /> 
  <_config:mapping xpath="CatalogGroupSelection/ConditionGroup/Condition/ConditionOperator" value="Operator" /> 
  <_config:mapping xpath="CatalogGroupSelection/ConditionGroup/Condition/ConditionAttributeValue/identifier" value="AttributeValueIdentifier" />
  <_config:mapping xpath="CatalogGroupSelection/ConditionGroup/Condition/ConditionAttributeValue/StringValue/Value" value="AttributeValue" /> 
  <_config:mapping xpath="CatalogGroupSelection/ConditionGroup/Condition/ConditionAttributeValue/language" value="LanguageId" />
  <_config:mapping xpath="CatalogGroupSelection/ConditionGroup/Condition/ConditionAttributeValue/UserData/UserDataField[0]/ValueType" value="ValueType" />
  <_config:mapping xpath="CatalogGroupSelection/ConditionGroup/Condition/UserData/UserDataField[0]/CondValField1" value="CondValField1" />
  <_config:mapping xpath="CatalogGroupSelection/ConditionGroup/Condition/UserData/UserDataField[0]/CondValField2" value="CondValField2" />
  <_config:mapping xpath="CatalogGroupSelection/ConditionGroup/Condition/UserData/UserDataField[0]/CondValField3" value="CondValField3" />
  <_config:mapping xpath="CatalogGroupSelection/ConditionGroup/Condition/UserData/UserDataField[0]/CondValField4" value="CondValField4" />
  <_config:mapping xpath="CatalogGroupSelection/ConditionGroup/Condition/UserData/UserDataField[0]/CondValField5" value="CondValField5" />
  <_config:mapping xpath="CatalogGroupSelection/ConditionGroup/Condition/UserData/UserDataField[0]/CondField1" value="CondField1" />
  <_config:mapping xpath="CatalogGroupSelection/ConditionGroup/Condition/UserData/UserDataField[0]/CondField2" value="CondField2" />
  <_config:mapping xpath="CatalogGroupSelection/ConditionGroup/Condition/UserData/UserDataField[0]/CondField3" value="CondField3" />
  <_config:mapping xpath="CatalogGroupSelection/ConditionGroup/Condition/UserData/UserDataField[0]/CondField4" value="CondField4" />
  <_config:mapping xpath="CatalogGroupSelection/ConditionGroup/Condition/UserData/UserDataField[0]/CondField5" value="CondField5" />
  <_config:mapping xpath="" value="Delete"  deleteValue="1"/> 
</_config:DataMapping>

Business object mediator

The mediator class name is com.ibm.commerce.catalogfilter.dataload.mediator.CatalogFilterConditionMediator.

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.