Feature Pack 6

Modifying the Aurora starter store to display the profit margin only in store preview

In this lesson, the Aurora starter store is customized to display the profit margin for recommended product in store preview only. This can help us verify the result in later testing.

You must configure the profit margin field to map the fields into your UserData within the CatalogNavigationViewType noun. This noun is used for search results. With the mapping complete, the fields can be extracted and displayed in the Aurora starter store.

Since the profit margin is related to price, it makes sense to display it after the offer price. Therefore, we will modify the price display widget to display profit margin after the offer price.

About this task

Procedure

  1. Open the following file:

    WC_eardir\Stores.war\Aurora\Widgets\ESpot\ProductRecommendation\ProductRecommendation_Data.jspf

  2. Locate the following code:
    <c:if test="${!empty catentryIdList || !empty nondisplayableDKList}">
      <c:set var="pageView" value="${param.pageView}"/>		
      <c:set var="exprBuilder" value="getCatalogEntryViewPriceWithAttributesByID"/>
      <c:set var="searchProfile" value="IBM_findCatalogEntryPriceWithAttributes_PriceMode"/>
  3. Change the value searchProfile to be your new search profile.
    For example, X_findCatalogEntryProfitMargin.
    <c:if test="${!empty catentryIdList || !empty nondisplayableDKList}">
      <c:set var="pageView" value="${param.pageView}"/>	
      <c:set var="exprBuilder" value="getCatalogEntryViewPriceWithAttributesByID"/>
      <c:set var="searchProfile" value="X_findCatalogEntryProfitMargin"/>
  4. Open the following file:

    WC_eardir\Stores.war\Aurora\Widgets\PriceDisplay\PriceDisplay_UI.jspf

  5. Add the following code at the bottom of the file:
    <c:if test="${env_inPreview && !env_storePreviewLink}">
      <c:if test="${!empty catalogEntryDetails.userData.userDataField.ProfitMargin}">
        <div> Profit Margin: ${catalogEntryDetails.userData.userDataField.ProfitMargin}% </div>
      </c:if>
    </c:if>
    Note: The profit margin displays only in store preview and only if the value exists and is not empty. Also, profitMargin is the example index field name that is used in this tutorial. Ensure that you use the same index field name, which you defined when you updated your search schema.xml, in the code snippet above.
  6. Save your changes and close the file.

Results

If you launch store preview from Management Center, you will be able to see the profit margin after the offer price.

Modify store preview results

However, when shoppers view store front page directly, they are unable to see the profit margin information.