Developer work to define product recommendations includes modifying ISML templates, defining content slots, providing a unique ID, along with other customizations.
When implementing product recommendations, keep the following in mind:
dw.util.Collection
of products. This option
enables you to create and use recommendations based on selected
products (up to 5), or all products in the basket.This example <islot> tag shows how to define a slot for use on a product detail page:
<isslot id="myslotid" context="global" context-object="${pdict.Product}"/>
This example shows how to define a slot for use on a category landing page:
<isslot id="cat-banner" context="category" context-object="${pdict.ProductSearchResult.category}" />
For defined content slots on your storefront, make sure to create a page template to render the recommended products. If you already have a template that renders other types of product content slots, you can reuse these templates with some modification. When reusing a template, copy it to the /templates/default/slots/recommendation/ folder.
The following example provides a product template for showing product recommendations:
<iscontent type="text/html" charset="UTF-8" compact="true"/>
<iscomment> should not be cached, the tiles are cached individually.</iscomment>
<isif condition="${slotcontent}">
<div class="product-listing product-listing-1x4">
<h2>${slotcontent.calloutMsg}</h2>
<ul class="search-result-items tiles-container">
<isloop items="${slotcontent.content}" var="product" begin="0" end="3">
<isobject object="${product}" view="recommendation">
<li class="grid-tile">
<isinclude url="${URLUtils.url('Product-HitTile',
'pid', product.ID,
'showswatches', 'true',
'showpricing', 'true',
'showpromotion', 'true',
'showrating', 'true')}"/>
</li>
</isobject>
</isloop>
</ul>
</div>
</isif>
When developing slot-rendering templates for product recommendations, make sure that slot content caching is performed properly. Due to the dynamic nature of product recommendations, make sure not to cache the entire slot. If you cache the entire slot, every visitor experiences the same recommendations. Instead of caching the entire template, ensure that caching occurs when rendering individual product tiles.