Developer Considerations for Einstein Product Recommendations

To implement Einstein Product Recommendations, modify ISML templates, define content slots, provide a unique ID, and make other customizations.

When you implement Einstein Product Recommendations, keep these points in mind:

  • Modify ISML templates to define content slots and show Einstein Product Recommendations.
  • When you define content slots for Einstein Product Recommendations, give the slot a unique ID and set the context to global.
  • If the content slot renders recommendations on product detail or category-landing pages, include the referring product ID or category ID as part of the context-object attribute.
  • Pass the context-object attribute a basket or dw.util.Collection of products. This option creates and uses recommendations based on selected products (up to 5), or all products in the basket.

This example <isslot> tag shows how to define a slot for use on a product detail page:

1<isslot id="myslotid" context="global" context-object="${pdict.Product}"/>

This example shows how to define a slot for use on a category landing page:

1<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, reuse these templates with some modification. When reusing a template, copy it to the /templates/default/slots/recommendation/ folder.

This example shows a product template for Einstein Product Recommendations:

1<iscontent type="text/html" charset="UTF-8" compact="true"/>
2<iscomment> should not be cached, the tiles are cached individually.</iscomment>
3
4<isif condition="${slotcontent}">
5<div class="product-listing product-listing-1x4">
6        <h2>${slotcontent.calloutMsg}</h2>
7
8        <ul class="search-result-items tiles-container">
9                <isloop items="${slotcontent.content}" var="product" begin="0" end="3">
10                        <isobject object="${product}" view="recommendation">
11                                <li class="grid-tile">
12                                        <isinclude url="${URLUtils.url('Product-HitTile',
13                                                'pid', product.ID,
14                                                'showswatches', 'true',
15                                                'showpricing', 'true',
16                                                'showpromotion', 'true',
17                                                'showrating', 'true')}"/>
18                                </li>
19                        </isobject>
20                </isloop>
21        </ul>
22
23</div>
24</isif>

When you develop slot-rendering templates for Einstein Product Recommendations, don’t cache the entire slot. Einstein Product Recommendations are dynamic, so caching the entire slot shows the same recommendations to every visitor. Cache individual product tiles instead of the entire template.