Product Recommendations
Product recommendations form a part of an Ecommerce strategy where products are dynamically shown to customers based on e.g. previous purchases or the context. Product recommendations are especially valuable to an organization with a diverse product catalog, where products may go together but not be organized together and therefore not naturally show up together in a shop.
There are a couple of different ways to create product recommendations in Dynamicweb:
- By adding related products
- By using index-based recommendations
Read more below.
Related Products
The oldest and most basic way of creating a product recommendation – of sorts – is to add Related products to a product. When you do this you simply open the product, click the Related products button, create or select a relation group (label), and select one or more products to relate to the product using this label.
The selected products can then be rendered in frontend using either the ProductRelatedGroups-loop (TemplateTags) or the Dynamicweb.Ecommerce.Services.ProductRelated service (ViewModels).
Index-based recommendations
As of Dynamicweb 9.10, you can set up product recommendations based on three fields in the product index:
- OrderCount contains a list of the products which appear in most orders in the previous 60 days
- OrderCountGrowth contains a list of the products which has seen the largest growth in orders this week compared to the previous week
- BoughtWithProducts contains lists of products bought alongside other products in the past 60 days
This guide will go through the basic steps of creating simple product recommendations based on these fields. It is presumed that you have an product index set up which uses the ProductSchemaExtender and contains the new fields.
Most Sold in Group & Trending Products
The Order Count and Order Count Growth fields are integer fields – which means that they contain a number. As such, it rarely makes sense to use them in expressions – you’re usually not interested in testing whether a product is over or under a given value in sales, you typically only just want to return the most sold products or the most trending products in a given context.
To create a Most sold in group query:
- Create a new query
- Create a GroupID parameter
- Create a set of expressions for returning active products in the relevant language and shop context – like you would for any basic product query –
- Add an expression where GroupIDs contains a value matching the GroupID parameter value
- Add sorting on the Order count field in descending order
Your query definition could end up looking like Figure 4.1.
You then use this query in a product catalog with a product list template rendering e.g. the first 3 products – the most sold products – in some way (Figure 4.2).
BoughtWithProducts
The BoughtWithProducts field is a little different – it does not contain a numerical value, but instead lists of products bought alongside other products. Long story short, you use this field to create Often bought with this product sections on e.g. a product details page.
To crate an Often bought with query:
- Create a new query
- Create a parameter to pass product IDs to – but don’t call it ProductID, call it PID or something like it*
- Create a set of expressions for returning active products in the relevant language and shop context – like you would for any basic product query
- Add an expression which checks if the Bought with products field contains the value from the PID parameter
Your query could end up looking like Figure 5.1.
When you pass this query a ProductID in the URL it will return a list of products often bought alongside the product ID passed to it, this data can then be rendered in a feed and added to your product details page using ajax, in an iframe, or in other neat and clever ways which are beyond this simple technical writer.
In practical terms this means that you can create a query and pass a product ID to it, then you will get a list of products back which are often bought alongside the ID you passed to the query.
* If you use the parameter name ProductID the product catalog will automaticlly use the ‘Details’ template. This template typically uses the ProductViewModel - which does not contain a Products property for you to loop through. I mean, your setup could be totally different – in which case you are free to use ProductID as your parameter.