DEV Community

Cover image for Mastering Magento 2 + AI Product Recommendation đŸ€–đŸ›’
Rafael CorrĂȘa Gomes
Rafael CorrĂȘa Gomes

Posted on • Originally published at linkedin.com

Mastering Magento 2 + AI Product Recommendation đŸ€–đŸ›’

Product Recommendations are surfaced on the storefront in the form of units such as “Customers who viewed this product also viewed”, “Customers who bought this product also bought”, “Recommended for you”, and so on. Magento’s Product Recommendations are powered by Adobe Sensei, which uses artificial intelligence and machine-learning algorithms to perform a deep analysis of aggregated shopper data. This data, when combined with your Magento catalog, results in highly engaging, relevant, and personalized experiences for the shopper.

How does it work? ⚙

As you might know, Magento’s Product Recommendations are deployed as a SaaS service, once the recommendation modules are installed and configured, your storefront will begin collecting behavioral data. Adobe Sensei processes this behavioral data along with your catalog data and calculates product associations that are leveraged by the recommendations service. At this point, the merchant can create, manage, and deploy product recommendation units to their storefront directly from the Admin UI.

Adobe product recommendation

How to install it?

Install the magento/product-recommendations module with Composer:

composer require magento/product-recommendations
Enter fullscreen mode Exit fullscreen mode

Don't forget to keep it updated, you can check if there is a new version available directly in your terminal executing this command bellow, the version with asterisks is your current version, and the others are the available versions.

composer show magento/product-recommendations --all | grep versions
Enter fullscreen mode Exit fullscreen mode

You can use this command below to update it.

composer update magento/product-recommendations --with-dependencies
Enter fullscreen mode Exit fullscreen mode

Add Page Builder support

Product Recommendations for Page Builder is an optional module and is installed separately.

composer require magento/module-page-builder-product-recommendations
Enter fullscreen mode Exit fullscreen mode

Page Builder

Recommendations & Events âšĄïž

You can check your recommendations accessing Marketing > Promotions > Product Recommendations in your Magento 2 admin panel.

Where can I see it?

When you create a new recommendation you can choose the position, at the bottom of the main content or at the top of the main content.

Which are the available recommendation?

Magento provides the following types of recommendations:

  • Most viewed - Recommends items most viewed by shoppers within the last seven days
  • Most purchased - Recommends items most purchased by shoppers within the last seven days
  • Most added to cart - Recommends items most frequently added to carts by shoppers within the last seven days
  • Recommended for you - Recommends items based on each shopper’s current and previous on-site behavior
  • Viewed this, viewed that - Recommends items most often viewed by shoppers who viewed the specified item
  • Viewed this, bought that - Recommends items most often purchased by shoppers who viewed the specified item
  • Bought this, bought that - Recommends items most often purchased by shoppers who purchased the specified item
  • More like this - Recommends items based on similar content and attributes
  • Trending - Recommends items based on the recent momentum of the product’s popularity

How Magento detects the behavior?

The module tracks the data following these user events below.

  • add-to-cart A product is added to the cart

  • add-to-wishlist A product is added to the wishlist

  • apply-discount-action A discount code is applied to the cart

  • edit-product-qty The quantity of a product in a cart changed to a non-zero value

  • initiate-checkout The customer initiates the checkout

  • instant-purchase The customer completes an instant purchase.

  • place-order The customer’s order is submitted

  • remove-discount-action A discount code is removed from a cart

  • remove-from-cart A product is removed from a cart

  • remove-from-wishlist A product is removed from a wishlist

  • sign-in The customer signs into their account

  • sign-out The customer signs out of their account

  • view The customer views a product details page (PDP)

Best practices 💡

Diversify your recommendation types. Customers start ignoring recommendations if they suggest the same products over and over again.
Do not deploy the same recommendations to your cart page and order confirmation page. Consider using Most Added to Cart for the cart page and Bought This, Bought That for the order confirmation page.
Keep your site tidy. Do not deploy more than three recommendation units on the same page.
If your store sells clothing, the More like this recommendation can suggest gender-specific items that do not match the gender of the product being viewed. Consider only using this recommendation type for non-clothing categories.
If you just started to use it, you can define these recommendation types to these pages below.

  • Home page Recommended for you

  • Product page Viewed this, viewed that

  • Cart Bought this, bought that

What's a visual similarity recommendation?

The Visual similarity recommendation type is a beta feature available through an optional module that recommends similar looking products to the product being viewed. This recommendation type is most useful where images and visual aspects of the products are important parts of the shopping experience. Visual similarity includes aspects such as:

  • Color
  • Shape
  • Size
  • Texture
  • Material
  • Style

If you are testing this recommendation type in a non-production environment, make sure your image URLs are publicly accessible. Because this recommendation type is not applicable to most catalogs, it is not enabled by default. You must explicitly enable this recommendation type.

You can install it using this command below.

composer require magento/module-visual-product-recommendations
Enter fullscreen mode Exit fullscreen mode

The Visual similarity recommendation type is available when you install an optional module. To enable it, you need to go to the Marketing > Promotions > Product Recommendations page, then access the Settings, and in the Visual Recommendations section, select to Enable Visual Recommendations.

You can use it on the product details page and use the storefront label “Inspired by this style” for example.

Bonus Master Tips đŸ€©

Generate behavior data

Use one of the non-production SaaS Environment IDs for configuration in the Magento Admin, then generate the data yourself by clicking around your storefront to mimic the behavior of actual shoppers.

  • Most Viewed - Requires minimal input data. Users need to view products.
  • Viewed this, viewed that - Requires multiple users to view multiple products.
  • Bought this, bought that - Requires multiple users to purchase multiple products.

If you don't see anything, probably it's because you don't have large amounts of behavioral data.

Test it in UAT

You can test the product recommendations in UAT using the production data, you just need to access the configuration of the recommendations and click into Fetch recommendations from a different SaaS environment, these are some important points to be aware of:

  • If you use AdBlock or any other tools to avoid ads it won't work
  • Configure a cookie domain and cookie path in your admin panel
  • UAT must be populated with the same products that you have in production
  • UAT won't show clickable links
  • You will see out-of-stock products if they are allowed to be shown in the catalog
  • Exclude categories

You can select up to 25 categories to be excluded from each recommendation.

Limitations

Customer grouped pricing - Product recommendations do not support customer grouped pricing. Recommendations do support regular and special pricing.
Bundled and grouped products - Product recommendations do not support bundled and group products. These products will not be shown in a recommendation unit.
Category permissions - Recommendations do not filter based on if customers or segments only have visibility to certain categories or products. The result is that shoppers might see recommendations for products they do not have access to.
Not sufficient data

The following recommendation types will fallback to Most viewed if there is not sufficient input data collected:

  • Recommended for you
  • Viewed this, viewed that
  • Viewed this, bought that
  • Bought this, bought that
  • Trending
  • Releases

Keep checking the releases: Magento 2 Product Recommendation Adobe Sensei Releases

Thank you! 😉

Thank you for checking it out, I hope this quick guide helps you, and if you want more details you can check the Magento 2 Product Recommendations User Guide.

Top comments (0)