Product Recommendation is a type of product association that promotes products based on what other customers are buying. For a "source" product on display, Product Recommendation targets products that were bought by customers who buy the source product. For example, Customer A bought a Canon camera and a Kingston SD card. When Customer B enters the Canon Camera's product page, Product Recommendation recommends Customer B to also buy a Kingston SD card.
Product Recommendations are computed by the ProductRecommendationService Quartz job in the Commerce Manager.
Key classes and files
- ProductAssociation - A representation of the link between a source and target product.
- ProductRecommendationService - A service for computing product recommendations.
- RecommendationSet - A set of product recommendations computed by the ProductRecommendationService.
- productMacros.vm - A Velocity template for displaying products.
How it works
Product Recommendation Calculation
ProductRecommendationService uses the algorithm in updateRecommendations() to compute product recommendations:
- Retrieve purchase data from the database as (CustomerId, ProductId) tuples, where the customer CustomerID bought the product ProductID.
- Convert the purchase data into a map where the customerId is the key and the list of products purchased is the value.
- Create a map of product recommendations by mapping each source product to other products they were purchased with.
- This map maps product ids to RecommendationSet instances. RecommendationSet counts the number of times other products were purchased with the source product and sorts the results in decreasing order. RecommendationSet returns the top N most frequent products as recommendations.
- For each source product with recommendations:
- Load the source product and its ProductAssociations
- Remove any product recommendation type ProductAssociations that are not in the new product recommendations set.
- Add any new product recommendations as new product recommendation type ProductAssociations.
Configuring Product Recommendation
The Product Recommendation calculation schedule is configurable via the Commerce Manager's quartz configuration file.
To configure the max number of days of order history to use in Product Recommendation computation, change the COMMERCE/STORE/PRODUCTRECOMMENDATIONS/numberOrderHistoryDays system setting.
To configure the max number of most frequent products to use as recommendations, change the COMMERCE/STORE/PRODUCTRECOMMENDATIONS/numberMaxRecommendations system setting.
To disable product recommendation, you can assign a -1 to either of the above system settings.
Disabling product recommendation will not remove existing product recommendations.