Catalog filter customization: Customizing matching rules

You can configure the matching rules for catalog filter conditions. Matching rules connect the data types of the catalog entry properties, or attribute dictionary attributes using String, Integer and Float data types. With customization you can additional matching rules.

Procedure

This example procedure outlines the high-level steps to create a matching rule, contains. The conditions are based on attributes and properties using the String type, the matches are partial.
  1. Define the matching rule in the Management Center user interface:
    • LOBTools\WebContent\config\commerce\price\objectDefinitions\CatalogFilterAttributeReferenceObjectDefinition.def
    • LOBTools\WebContent\config\commerce\price\objectDefinitions\CatalogFilterCatentPropertyChildObjectDefinition.def

    In these files, find the <wcfPropertyDefinition propertyName="operator"> .

    Append the following code.

    <wcfPropertyDefinition propertyName="operator" displayName="${cftCatalogFilterResources.catalogFilterAttributeOperator}" required="true">
    	……
    	// This matching rule only applied to String type property or attribute
    	<PropertyValue displayName="${extCatalogFilterResources.catalogFilterOperatorStringContains}" value="STRING_CONTAINS">
    			<EnablementCondition conditionId="stringCondition" enablementValue="String" propertyName="attrType" />
    	</PropertyValue>	
    </ wcfPropertyDefinition>
  2. Customize the runtime code to support the new matching rule. The catalog filter runtime code builds a search expression based a catalog filter the condition is composed in this expression. Build a search engine specific expression snippet for the new matching rule.
    In summary:
    1. Create a class such as com.mycompany.catalogfilter.GetContainsStringExpressionCmdImpl that implements the interface com.ibm.commerce.contract.catalogfilter.command.GetConditionExpressionCmd and extends from com.ibm.commerce.command.TaskCommandImpl.
    2. Implement the logic for building your "contains" condition expression within performExecute method. The caller calls method setCondition to condition information including the attribute or property field name, the matching rule and values in a data object of type com.ibm.commerce.contract.catalogfilter.Condition. Provide the output to the caller in the method getExpression (the format is whose format is search engine specific).
    3. Using the following SQL statement as a guide, register the class implementation in the command registry:
      insert into CMDREG ("STOREENT_ID", "INTERFACENAME", "DESCRIPTION", "CLASSNAME", "PROPERTIES", "LASTUPDATE", "TARGET", "OPTCOUNTER") 
      values(0, 'com.ibm.commerce.contract.catalogfilter.command.GetConditionExpressionCmd+STRING_CONTAINS', NULL, 'com.mycompany.catalogfilter.GetContainsStringExpressionCmdImpl', NULL, NULL, 'Local', NULL);