How to Troubleshoot Product Recommendations Module in Magento 2

- E-Commerce, Magento 2

Magento 2 Development; Magento 2 tutorial

We’ve just reviewed the best Magento 2 personalization services, and the Magento 2 Product Recommendations module powered by Adobe Sensei is among them. The solution is delivered as a part of Magento Commerce, so you can use it by default without any necessity to connect to third-party platforms. However, the Product Recommendations module may not work correctly from time to time. In the following material, we shed light on how to troubleshoot possible issues related to the native Magento 2 personalization tool. More useful tips are collected in our Cookbook.

The Issue

The following guide describes resolutions for two different modules that power personalized product recommendations in Magento 2:

  • magento/productrecommendations – the module itself;
  • saasexport – its dependency.

As we’ve mentioned above, both tools are vital and cannot be replaced, so you need to troubleshoot them if any issues related to the Product Recommendations tool occurs. 

Since we are talking about a Commerce-specific feature that has been added in the latest Magento 2 version, the following recommendations are relevant for Magento Commerce 2.3.x.

Product Recommendations Module

If you didn’t configure the magento/product-recommendations module yet, we recommend you to check the official manual here: Install and Configure Product Recommendations. If any issues occur after the configuration, the following suggestions may help you fix them.

Leave it alone

Artificial intelligence and machine learning require time to provide any output. Since these technologies are a part of Adobe Sensei that powers Product Recommendations in Magento 2, you just need to leave the corresponding module alone for a while. The system will collect data regarding your customers, analyze it, and only then create personalized output. 

It is recommended to wait for at least 24 hours. This time is usually enough for the system to get the necessary insights to start working. 

If you don’t want to see product blocks empty, it is possible to deploy recommendation types that don’t depend on behavioral data. For instance, you can provide store visitors with a “More like this” widget or show bestsellers as long as the Product Recommendations module collects insights and transfers them to Adobe Sensei. 

So, if no configured recommendations appear on the frontend, there is not enough data to create them. You just need to let the system work in the background, exploring your customers.

Check credentials

If 24 hours have passed, but nothing happens, you may have problems with credentials. It is necessary to provide the system with a valid SaaS Environment ID or API Key

An error may occur during the product recommendations initialization after you specify your SaaS Environment ID or API key. To fix the issue, it is recommended to make sure that the entered SaaS Environment ID and API key are correct. You can learn how to link your Magento 2 website to a SaaS service via an API key in this article: Magento 2 Services

Now, let’s see how to ensure that the MageID and API key are linked. Usually, a user who owns the MageID typically holds the Magento license. To ensure that the MageID and API key are connected, such the user needs to generate the API key. However, it is possible to change the utilized MageID if necessary. You can contact the Magento Commerce support department to get help. Go to the Help Center and submit a ticket.

Take a look at cookie restrictions

Note that Magento collects behavioral data only when Cookie Restriction Mode is turned off. If it is enabled, the system can gather this information only if a shopper provides their consent.

To disable the mode, go to your Admin -> Stores -> Settings -> Configuration and choose Web in the left panel under the General tab. In the Default Cookie Settings section, set the Cookie Restriction Mode option to No. However, this action may be illegal in many countries, since you need to inform shoppers about the fact that you collect and process their data. For more information, read the official documentation: Cookie Restriction Mode.

magento 2 product recommendations troubleshooting cookies

Catalog SaaS Export module

Now, let’s see how to troubleshoot the Catalog SaaS Export (saasexport) module.

Cron

Firstly, you need to check whether the cron is enabled. If jobs are disabled, run cron from the command line. Use the following command options:

Note that “–group” specifies the cron group you want to run. However, it is possible to omit this option to enable cron for all groups. For instance, you can run the default cron job with this command:

Note that it is necessary to run cron twice:

  1. to discover tasks to run
  2. to run the tasks. 

Don’t forget to run the second cron on or after the scheduled_at time.

You can find more information about cron here: Magento 2 Cron Configuration.

Indexers

First of all, it is necessary to confirm that the Magento 2 indexers are running. You can find a guide that describes index management here: Manage Magento 2 Indexers.  

Next, check whether the Product Feed indexer is set to Update by Schedule. If not, do the following:

  1. Go to Admin -> System -> Tools -> Index Management.
  2. Select the checkbox next to the Product Feed indexer.
  3. From the Actions dropdown, choose the Update by Schedule indexing mode.
  4. Click Submit.

magento 2 product recommendations troubleshooting indexers

Modules

The saasexport metapackage installs the following modules:

First of all, you need to confirm that they are enabled. Run the following command to check the module statuses:

Next, check the logs to make sure that no errors associated with the modules above occur.

Cache

You also need to refresh the Configuration cache to troubleshoot the Product Recommendations Module in Magento 2. Follow these steps:

  1. Go to Admin -> System -> Tools -> Cache Management.
  2. Select the checkbox next to the Configuration cache.
  3. From the Actions dropdown, choose the Refresh option.
  4. Click Submit.

magento 2 product recommendations troubleshooting cache

Database 

You should also make sure that there is data in the catalog_data_exporter_products database table. Product Recommendations won’t work correctly if it is empty. 

Events

After you install and configure the Product Recommendations module, verify that the system successfully transfers behavioral data. Chrome’s developer tools are enough. Check this guide for further information: How to confirm event collection in Magento 2.

Final Words

You can quickly troubleshoot the Product Recommendations module in Magento 2. However, it is possible to avoid the issues described above by using such third-party personalization platforms as Nosto or Dynamic Yield. You can find reliable replacements for the default Magento 2 Product Recommendations here: The Best Personalization Services for Magento 2