Tutorial: Indexing profit margin data for use in dynamic product recommendation
Profit Margin (%) = (offer price - cost price) / offer price * 100
Although,
in WebSphere Commerce you can have offer prices for products in different
currencies and have a different range price, this tutorial guides
you to use the base offer price (the price that customers pay for
the product when they buy one unit of the product) in US dollar 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
WebSphere Commerce. You must either create a separate price list in
Management Center Catalog Filters and Pricing tool to manage the cost
prices, or you have the cost price list that is managed in an external
system. In this tutorial, you can have the cost prices managed externally and uploaded 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%.
- Preprocessing, where the highly structured relational data is flattened and stored in summary tables.
- The actual indexing, where data is extracted from the flattened tables and sent to the Solr indexes by using the Data Import Handler (DIH).
You must customize the index building process to calculate the profit margin and include it into the search index by configuring the DIH configuration file. After, you must add support for using the profit margin as a filter and sort criteria in product recommendations by registering the field in search attribute tables with the proper property names.
You must display the profit margin data in store preview to help you verify 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 in your storefront pages.
Learning objectives
- WebSphere Commerce search indexing
- Understand and customize WebSphere Commerce search
- Understand and customize the preprocessing and indexing process
- Understand and customize the product recommendation that is based on a custom field
Time required
Expect this tutorial to take 2 hours to complete. The tutorial takes longer if you explore concepts that are related to this tutorial.Skill level
This tutorial is intended for advanced WebSphere Commerce developers responsible for creating and customizing WebSphere Commerce BOD services and customizing WebSphere Commerce search.- BOM configuration changes as used in the tutorial: Tutorial: Extending a BOD service to manage UserData with the Data Service layer. It is not mandatory to perform this tutorial, however you must understand the concepts and tasks that are contained in the tutorial.
- WebSphere Commerce search
- Web services
- XML
- WebSphere Commerce services
- Relational databases
- SQL
System requirements
Before you begin this tutorial, complete the following tasks:- Install WebSphere Commerce Developer Version 7
- Install WebSphere Commerce Developer Feature Pack 7
- Deploying the search server
- Managing WebSphere Commerce search
- Publishing the Aurora starter storeNote: In this tutorial we use Aurora to display the search customizations, but other storefronts that support WebSphere Commerce Search can be used as well.
Tutorial resources
- Tutorial source code, for reference: profit_margin_source_fep7.zip
- Cost price data: costprice_data.csv