< Previous | Next >

Customize the UserData property name mapping and search configuration

In this lesson, you modify the UserData field name mapping to map the new columns to the UserData field of the CatalogEntryView noun. You also create a search profile to return our custom data. As a result, the search results in the store can include the customer ratings data.


Procedure

  1. Modify the user data field name mapping to map the customer ranking field to a user data.

    1. Open WebSphere Commerce Developer and switch to the Enterprise Explorer view.

    2. Expand workspace_dir > Search-config-ext > runtime > config > com.ibm.commerce.search. If this directory does not exist, create the directory.

    3. Open the wc-component.xml file for editing. If this file does not exist, we must create this file. See Changing properties in the component configuration file (wc-component.xml).

    4. Add the following mapping into your file before the end of the </_config:valuemappingservice> element.

        <_config:valuemapping externalName="CatalogEntryUserDataFieldNameMapping" internalName="CatalogEntryUserDataFieldNameMapping">
        <_config:valuemap externalValue="x_customerRanking" internalValue="customerRanking_display" />
        </_config:valuemapping>

      If we created the file as part of completing this tutorial, your complete file can resemble the following code.

        <?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:valuemappingservice>
            <_config:valuemapping externalName="CatalogEntryUserDataFieldNameMapping" 
               internalName="CatalogEntryUserDataFieldNameMapping">
              <_config:valuemap externalValue="x_customerRanking" internalValue="customerRanking_display" />
            </_config:valuemapping>
          </_config:valuemappingservice>
        </_config:DevelopmentComponentConfiguration>

    5. Save our changes and close the file.

  2. Modify the search configuration file so that the value of the customer ratings field can return in a new search profile.

    1. In the search-config-ext > runtime.config > com.ibm.commerce.search directory, open the wc-search.xml file for editing. If this file does not exist, we must create this file. See Changing properties in the component configuration file (wc-component.xml).

    2. Add the following code to configure the new search profile for the customer ratings before the end tag of the file, </_config:search-config>.

        <_config:profile name="IBM_findProductsBySearchTerm" indexName="CatalogEntry">
          <_config:query>  
            <_config:postprocessor 
            classname="com.ibm.commerce.foundation.server.services.rest.search.postprocessor.solr.SolrRESTSearchCatalogEntryViewUserDataQueryPostprocessor" />  
          </_config:query>   
          <_config:result>           
            <_config:field name="customerRanking_display"/>
          </_config:result>            
        </_config:profile>

      • This code uses the IBM_findProductsBySearchTerm search profile.

      • This code adds the com.ibm.commerce.foundation.server.services.rest.search.postprocessor.solr.SolrRESTSearchCatalogEntryViewUserDataQueryPostprocessor postprocessor into the specified search profile. The purpose of this postprocessor is to populate and map UserData that is defined in the wc-componemt.xml file into the final catalog entry REST response.

      Note:

      Note: customerRanking_display is the example index field name used in this tutorial. Ensure that you add the index field name that we defined when you updated our search x-schema.xml file.

    3. Save and close the file.

  3. Restart the WebSphere Commerce Test Server. To ensure that WebSphere Commerce picks up the changes that you made in this lesson and earlier lessons, we must restart the test server.

< Previous | Next >