Magento – Recently viewed products not showing for NOT LOGGED CUSTOMERS in magento 2

magento2recently-viewed

Why recently view products not showing on product view page if any customer not logged.
When customer logged in their account then recently view product showing on product view page.
if customers log out from their account then recently view products not showing on product view page.
Anyone know above problem why above error generating?
using code below
<?php echo $this->getLayout()
->createBlock("Magento\Reports\Block\Product\Widget\Viewed")
->setDisplayType("recently.view.products")->setProductsCount("4")
->setTemplate("widget/viewed/content/viewed_list.phtml")->toHtml(); ?>

Best Answer

There is an Admin setting that will show the Recently Viewed Products for Not Logged in Customers.

Go to Admin => Stores > Settings > Configuration > Catalog > Recently Viewed/Compared Products select Yes to ( Synchronize widget products with backend storage )

Clear cache and check.

Related Topic