Recommendations - Magento 2

Magento 2 Recommendations Script

If you are using Magento 2, the recommendations script for require JS is different. You need to replace the first line in the default script found in the recommendations section with the following:

Default Script

default recommendations script

New Script Line

<script>
  var dfUrl = 'https://cdn.doofinder.com/recommendations/js/doofinderRecommendation.min.js';
  (function(c,o,k,e){var r,t,i=setInterval(function(){t+=c;r=typeof(require)==='function';
  if(t>=o||r)clearInterval(i);if(r)require([k],e)},c)})(100, 10000, dfUrl);
</script>

Final Script

The final script should look like this:

<script>
  var dfUrl = 'https://cdn.doofinder.com/recommendations/js/doofinderRecommendation.min.js';
  (function(c,o,k,e){var r,t,i=setInterval(function(){t+=c;r=typeof(require)==='function';
  if(t>=o||r)clearInterval(i);if(r)require([k],e)},c)})(100, 10000, dfUrl);
</script>
<df-recommendations
  hashid="5bdf17409acaa64fd36fc4fcf7c25820"
  total-products="10">
</df-recommendations>

How To Add The Recommendation Widget To A Magento Page

Step 1: Login into your Magento Admin Panel. Step 2: On the left side menu, look for 'Content' > click on 'Pages'.

recommendations magento 2

Step 3: Locate the Page you want to add the widget to, go to Action > click on 'Select' > click on 'Edit'. Make sure to check if the page is Enabled.

recommendations magento 2

Step 4: Open the 'Content' section, and click on 'Edit with Page Builder'.

Step 5: On the left side menu, search for the element "Elements". Select and drag the "HTML Code" block to the page section you desire.

Step 6: Once placed, click on the wheel icon to Edit the HTML Code.

Step 7: Copy and Paste the "Final Code" you see on this article above. Remember you must replace the Hash ID with the Hash ID from your website.

Step 8: Remember to 'Save' the changes.

recommendations magento 2

🗒 Note: Please note that in order to work properly, the Recommendations must also be activated in your Doofinder Admin.