Feature Pack 6

Customizing the Business Object Mediator and search configuration to include custom data

In this lesson, the Business Object Mediator is modified to map the new columns to the user data field of the CatalogEntryView noun.

About this task

You also create a search profile to return you profit margin data. As a result, the search results in the Aurora starter store include the newly added profit margin data.

Procedure

Modify the business object mediator to map the profit margin field to a user data.
  1. Navigate to the com.ibm.commerce.catalog-ext directory. If this directory does not exist, you must create the directory.

    WC_eardir\xml\config\com.ibm.commerce.catalog-ext

  2. Open the wc-business-object-mediator.xml file. If it does not exist, you must create this file.
    For an example of BOM configuration changes, see the tutorial: Tutorial: Extending a BOD service to manage UserData with the Data Service layer
  3. Add the following mapping in bold:
    <_config:object logicalType="com.ibm.commerce.catalog.facade.datatypes.CatalogNavigationViewType"
      physicalType="com.ibm.commerce.catalog.facade.server.services.search.metadata.solr.SolrCatalogNavigationViewImpl">
      <_config:mediator interfaceName="com.ibm.commerce.foundation.server.services.dataaccess.bom.mediator.ReadBusinessObjectMediator"
        className="com.ibm.commerce.catalog.facade.server.services.dataaccess.bom.mediator.solr.SolrReadCatalogNavigationViewMediator">
        <_config:mediator-properties>
          <_config:mediator-property name="CatalogEntryView/UserData[(Name='ProfitMargin')]" value="profitMargin" />
        </_config:mediator-properties>
      </_config:mediator>
    </_config:object>
    If you must create this file, your complete file can resemble the following code:
    <?xml version="1.0" encoding="UTF-8"?>
    <_config:BusinessObjectMediatorConfiguration
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
      xsi:schemaLocation="http://www.ibm.com/xmlns/prod/commerce/foundation/config ../xsd/wc-business-object-mediator.xsd" xmlns:_config="" class="inlinelink" target="_blank">http://www.ibm.com/xmlns/prod/commerce/foundation/config">;
    
      <_config:object logicalType="com.ibm.commerce.catalog.facade.datatypes.CatalogNavigationViewType"
    physicalType="com.ibm.commerce.catalog.facade.server.services.search.metadata.solr.SolrCatalogNavigationViewImpl">
        <_config:mediator interfaceName="com.ibm.commerce.foundation.server.services.dataaccess.bom.mediator.ReadBusinessObjectMediator"
    className="com.ibm.commerce.catalog.facade.server.services.dataaccess.bom.mediator.solr.SolrReadCatalogNavigationViewMediator">
          <_config:mediator-properties>
            <_config:mediator-property name="CatalogEntryView/UserData[(Name='ProfitMargin')]" value="profitMargin" />
          </_config:mediator-properties>
        </_config:mediator>
      </_config:object>
    </_config:BusinessObjectMediatorConfiguration>
  4. Save your changes and close the file.
Then, modify the search configuration file to let it return the value of the profit margin field in a new search profile.
  1. Navigate to the com.ibm.commerce.catalog-ext directory.

    WC_eardir\xml\config\com.ibm.commerce.catalog-ext

  2. Open the wc-search.xml file. If it does not exist, you must create this file.
    For an example of changing properties in search configuration file, see the task: Changing properties in the search configuration file (wc-search.xml) (WC EAR)

    Add the following profile configuration before the end tag </_config:search-config>:

    <_config:profile name="X_findCatalogEntryProfitMargin" extends="IBM_findCatalogEntryPriceWithAttributes_PriceMode">
      <_config:result inherits="true">
        <_config:field name="profitMargin" />
      </_config:result> 		        
    </_config:profile>
    
    • This code defines a new search profile that is called X_findCatalogEntryProfitMargin. This name includes the prefix 'X_' that indicates that this is a customized search profile.
    • This new profile extends an existing search profile IBM_findCatalogEntryPriceWithAttributes_PriceMode. This profile is used in your store JSP file to retrieve the price data. This profile is defined in the following file: Stores\WebContent\Aurora\Widgetsz\ESpot\ProductRecommendation\ProductRecommendation_Data.jspf. You modify this file to use your new profile in the next lesson.
    • In your newly defined profile X_findCatalogEntryProfitMargin, you also add the field profitMargin in the result so that the profit margin is returned.
    Note: profitMargin is the example index field name that is used in this tutorial. Ensure that you add the index field name that you defined when you updated your search schema.xml file.
  3. Save your changes and close the file.
  4. To ensure that WebSphere Commerce picks up the changes you made in your business object mediator and search configuration file, you must restart your WebSphere Commerce server.