Introduced in Feature Pack 2

Adding the new search profile

Introduced in Feature Pack 2

In this lesson, the search query is customized to search on the default predefined search fields, and on one or more of the new fields that are defined for warranty. This is achieved by extending the wc-search.xml file to include a custom search profile definition that extends an existing profile.

Once the mapping is configured, you add a search profile. The search profile is used to control the fields that are used in the search query. WebSphere Commerce provides predefined default search profiles. The common search profile uses the product name and short description fields in the search query. These search profiles have a hierarchical structure and can be extended. This tutorial demonstrates how to extend one of the predefined search profiles to include the fields from the warranty definition. From the user interface, the search profiles are used in the JSP files. Selecting the correct profiles are necessary to search on the correct search fields. It is demonstrated how the advanced search page can be modified to use the newly defined search profile.

Note: This tutorial only extends the IBM_findCatalogEntryByNameAndShortDescription profile so that you can search on more fields. This extension is completed by creating a custom profile in the wc-search.xml file. For more information on other profiles in the wc-search.xml file that you can extend and the effects of changing these profiles, see WebSphere Commerce search configuration file (wc-search.xml) (WC EAR). If you are looking to modify an existing property within a existing WebSphere Commerce profile, a custom profile is not required. For more information about making changes to these WebSphere Commerce profiles, see Changing properties in the search configuration file (wc-search.xml) (WC EAR).

Procedure

  1. Review the wc-search.xml file to view the profile you will be extending in this tutorial.
    1. Go to the WC/xml/config/com.ibm.commerce.catalog-fep directory:
    2. Open the wc-search.xml file.
    3. Find the definition of the IBM_findCatalogEntryByNameAndShortDescription. You extend this profile to add the custom functionality:
      
      <_config:profile extends="IBM_findCatalogEntryByName" name="IBM_findCatalogEntryByNameAndShortDescription">
      <_config:query inherits="true">
      <_config:field name="shortDescription"/>
      </_config:query>
      <_config:highlight inherits="true">
      <_config:field name="shortDescription"/>
      </_config:highlight>
      </_config:profile>
      
  2. Add a custom search profile.
    1. Create a file that is named wc-search.xml in the WC/xml/config/com.ibm.commerce.catalog-ext directory.
      Note: If you have completed a previous warranty tutorial, this directory might exist.

      Add the new search profile definition called X_findCatalogEntryByWarranty:

      
      <?xml version="1.0" encoding="UTF-8"?>
      
      <_config:search-config
      xmlns:_config="http://www.ibm.com/xmlns/prod/commerce/foundation/config"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.ibm.com/xmlns/prod/commerce/foundation/config ../xsd/wc-search.xsd ">
      
      
      <_config:profile name="X_findCatalogEntryByWarranty"
      extends="IBM_findCatalogEntryByNameAndShortDescription">
      <_config:query inherits="true">
      
      <_config:field name="warterm" />
      <_config:field name="wartype" />
      <_config:field name="careinstruction" />
      </_config:query>
      
      </_config:profile>
      </_config:search-config>
      
    2. Save your changes and close the file.

      With this new profile created, search queries can be submitted that can search on warterm, wartype and careinstruction.