Multiple Anchor Product Recommendations

Passing multiple products anchors to Commerce Cloud Einstein enables you to support product recommendations from the items within a shoppers cart. Using customer specific items, Einstein recommends products tailored to each individual shopper that may have not been suggested based on standard product recommendation methods.

Optimize Code for Multiple Anchor Recommendations

Some development work is required to process multiple product anchors. Personal implementation can vary substantially, but generally the API calls remain the same.

  1. Locate the shipments loop in cart.isml and implement the code as outlined below.
    Note: This can be done wherever you want to pass multiple anchors to the Commerce Cloud Einstein recommender.
    <iscomment> LOOP TO SEPARATE DIFFERENT SHIPMENTS ex: Gift Registry Shipments Etc.</iscomment> 
    <isloop items="${pdict.CurrentForms.cart.shipments}" var="Shipment" status="loopstate">
      // Add the following three lines:
            var productCollection : dw.util.Collection = new dw.util.ArrayList(); 
    <isloop items="${Shipment    .items}" alias="FormLi" status="loopstate"> 
        <isset name="lineItem" value="${FormLi.object}" scope="page" />
      // Add the following four lines: 
            if (lineItem.catalogProduct) {
            productCollection.add(lineItem.product); }
  2. Replace the existing recommendations slot with the new Einstein powered recommendation slot.
    <div class="cart-recommendations">
      // Add the following two lines:
        <isslot id="cart-multi3-product-collection" description="Multi for Cart page 3 - global - productCollection" 
            context="global" context-object="${productCollection}"/>
X Privacy Update: We use cookies to make interactions with our websites and services easy and meaningful, to better understand how they are used. By continuing to use this site you are giving us your consent to do this. Privacy Policy.