Tutorials > Management Center > Extend simple search in the Catalogs tool
Configure parametric search for custom data
In this lesson you reuse existing Catalog queries to perform the searches on the warranty data.
Procedure
- There are existing SQL statements defined in Catalog query template files, found in WC_EAR/xml/config/com.ibm.commerce.catalog/, with a filename extension of ".tpl". Open these files in a text editor and look up the string /CatalogEntry[(@catalogEntryTypeCode=) and search()] in them. You can find the existing SQL statement definition in the wc-query-CatalogEntry-admin-get.tpl file, as shown in the following code sample:
BEGIN_XPATH_TO_SQL_STATEMENT name=/CatalogEntry[(@catalogEntryTypeCode=) and search()] base_table=CATENTRY sql= SELECT DISTINCT CATENTRY.$COLS:CATENTRY_ID$ FROM CATENTRY JOIN STORECENT ON (CATENTRY.CATENTRY_ID = STORECENT.CATENTRY_ID AND STORECENT.STOREENT_ID IN ($STOREPATH:catalog$)) ,$ATTR_TBLS$ WHERE CATENTRY.CATENTTYPE_ID IN (?catalogEntryTypeCode?) AND CATENTRY.MARKFORDELETE = 0 AND ( $ATTR_CNDS$ ) ORDER BY CATENTRY.CATENTRY_ID $DB:UNCOMMITTED_READ$ END_XPATH_TO_SQL_STATEMENT
This SQL statement performs a parametric search of catalog entry nouns given the specified search criteria.
- Object path mappings allow the query to determine the corresponding column in the database table for a specified property. Before new properties can be used as search conditions in the query template, define these object path mappings:
- Open WebSphere Commerce Developer.
- In the Enterprise Explorer view, navigate to WC > config > com.ibm.commerce.catalog-ext and double-click the wc-component.xml file to open it in the default editor.
- Locate the _config:dataservice and add the mapping section to it. In the step Add object path mapping in extended wc-component.xml for extended properties of Tutorial: Adding new search conditions in the advanced search of the Catalogs tool, the mappings with WARTERM and WARTYPE have already been defined, add one more mapping to the CAREINSTRUCTION table. After this modification the whole wc-component.xml file will look like the following sample:
<?xml version="1.0" encoding="UTF-8"?> <_config:DevelopmentComponentConfiguration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.ibm.com/xmlns/prod/commerce/foundation/config ../xsd/wc-component.xsd " xmlns:_config="http://www.ibm.com/xmlns/prod/commerce/foundation/config"> <_config:dataservice dataMediatorType="JDBC" metadataClass="com.mycompany.commerce.catalog.facade.server.metadata.MyCompanyMetaData"> <_config:mapping> <_config:key name="CatalogEntry" /> <_config:basetable name="CATENTRY" useAllColumns="false"> <_config:associatedtable name="XWARRANTY" useAllColumns="false"> <_config:columns name="WARTERM" propertyName="UserData/UserDataField/Warterm" /> <_config:columns name="WARTYPE" propertyName="UserData/UserDataField/Wartype" /> </_config:associatedtable> <!-- new added for Tutorial: Extend Simple Search in Catalog Management Tool with Warranty Criteria --> <_config:associatedtable name="XCAREINSTRUCTION" useAllColumns="false"> <_config:columns name="CAREINSTRUCTION" propertyName="Description/Attributes/careinstruction" /> </_config:associatedtable> </_config:basetable> </_config:mapping> </_config:dataservice> </_config:DevelopmentComponentConfiguration>
- Save and close the file.
- Restart the WebSphere Commerce Test Server to load the new configuration