Doofinder logo

Support Documentation

Search icon
  • Help
  • Plugins
  • Magento
  • Installation Guide
  • Recommendations - Magento 2

Recommendations - Magento 2

Magento 2 - Recommendations Script

If you are using Magento 2, the Recommendations Script for required 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

Deprecated feature. Refer to the following documentation for updated information on the Recommendations product.

  1. Login into your Magento Admin Panel.
  2. On the left side menu, look for Content > Pages.
  3. recommendations magento 2
  4. Locate the Page you want to add the widget to, go to Action > Select > click on Edit. Make sure to check if the page is Enabled.
  5. recommendations magento 2
  6. Open the Content section, and click on Edit with Page Builder.
  7. On the left side menu, search for the element Elements. Select and drag the HTML Code block to the page section you desire.
  8. Once placed, click on the wheel icon to Edit the HTML Code.
  9. 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.
  10. Remember to save the changes.
recommendations magento 2

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

Did you find this page helpful?