HCL Commerce Version 9.1.12.0 or later

Tutorial: Indexing profit margin data using the Catalog Asset Model

In this tutorial, you customize HCL Commerce Search to use specific search conditions to dynamically recommend products to customers based on the profit margin for the products.

The profit margin of a product is how much profit, in percentage, that your store earns for every dollar of sale of the product. This tutorial uses the following formula to calculate the profit margin.
      Profit Margin (%) = (offer price - cost price) / offer price * 100
In HCL Commerce you can have offer prices for products in different currencies and have a different range price. This tutorial guides you through using the base offer price (the price customers pay for the product when they buy one unit) in US dollars to calculate the profit margin. You can use the other currency to calculate the profit margin as well. Cost prices are not stored by default in HCL Commerce. You must either create a separate price list in the Management Center Catalog Filters and Pricing tool to manage the cost prices or use an external system to manage the cost price list.

In this tutorial, you can manage the cost prices externally and upload them with the Catalog Filter and Pricing tool. For testing purposes, a sample cost price file is generated where the cost price of a product is set to 10% - 90% of the offer price. For example, if a product's offer price is USD $100, the cost price can be any value between USD $10 and $90. Therefore, the profit margin in this tutorial falls into the range of 10% - 90%.

After creating both offer and cost prices, you can calculate the profit margin and index it. The indexing process in HCL Commerce Search starts with the Ingest Service and involves ETL (Extract, Transform, Load) data flows in NiFi that are defined as Connectors. Connectors are connected data flow pipelines that are set up with NiFi process groups. The connector descriptor is added to ZooKeeper, and the actual connector is set up in NiFi. The Ingest Service and NiFi processes complete the extraction and transformation of the data for output for updating the Elasticsearch index. The process is similar to the Solr index preprocess but is more flexible and extensible.

Displaying the profit margin data in-store preview helps you verify that the correct products are being recommended. To display this profit margin in-store preview, the field must be added to the mediator configuration file. You can then add the control in the JSP file to display only the fields in store preview, not your storefront pages.

Note: Workspaces are not supported while you are completing this tutorial as the profit margin is not workspace-enabled since product recommendations are based on production-ready data.

Learning objectives

After completing this tutorial, you should be familiar with the following concepts and tasks
  • HCL Commerce search indexing
  • Understand and customize HCL Commerce search.
  • Understand and customize the preprocessing and indexing process.
  • Understand and customize the product recommendation that is based on a custom field.

Skill level

This tutorial is intended for advanced HCL Commerce developers responsible for creating and customizing HCL Commerce search.

To complete this tutorial, ensure that you are familiar with the following terms and concepts:

Prerequisites

Before you can index the profit margin data, you must load a cost price list using the Catalog Filter and Pricing tool.

After you create the customization in the development environment, you can deploy the customization into your runtime environment. This tutorial provides the steps to create the customization and also to deploy the customization.
  • HCL Commerce Version 9.1.12.0 or laterPrepare the development toolkit for NiFi following the instructions in Custom NiFi processors. The NiFi toolkit must be configured with Eclipse set to use the Java 1.8 compiler, with Maven Version 3.8.4 or above. Set the Java build path for the imported project to use JavaSE-1.8 libraries.
    Patch the Nifi container on the data platform and obtain the latest JAR files from the running patched container before you configure and build tutorial assets in the NiFi toolkit. As an example, for the Version 9.1.12 environment the JAR files are:
    1. commerce-search-processors-9.1.12.0.jar
    2. hcl-cache-core-9.1.12.0-20221201.221643-25.jar
    3. cf-base-9.1.12.0-20221123.064414-9.jar
  • To set up your custom NiFi development environment, see Create the customization in NiFi.
  • To create and deploy a custom NiFi processor, see Create and deploy a custom NiFi processor.
  • To create the customization for indexing profit margin data in your environment, see Create a custom connector using Ingest.
  • To deploy the customization for indexing profit margin data in your environment, see Configure the connector in NiFi.
Note:
  • In some places, the steps to complete the customization for your toolkit and runtime environments are different. In such cases, the different steps are provided.
  • In this tutorial, the storeId is considered as 1. Replace this with the storeId for your own store.
    Run the following SQL query to obtain the storeId for your store:
    SELECT STOREENT_ID FROM storeent WHERE IDENTIFIER="<storename>";
  • In this tutorial, the NiFi registry container name is considered as bvt_registry_1. Replace this value with the NiFi registry container name for your own setup.

Time required

Expect this tutorial to take two hours to complete. The tutorial takes longer if you explore concepts that are related to this tutorial.

Tutorial resources

Download and extract profit_margin_price_data.zip into a temporary directory in your development environment. This file includes the sample price data that you use in this tutorial. This sample data is targeted for an AuroraESite.