How to Programmatically Display Recently Viewed Products in Magento 2

How to Programmatically Display Recently Viewed Products in Magento 2

Have you ever brought an item on a recommendation from your friends or family? Or maybe a product recommendation pushed you to select it over some other product.

Well, for online stores, it comes as a “recently viewed products” section that encourages customers for conversion.

Displaying recently viewed products in an online store keeps the customer from distracting while browsing through your store. Optimize your sales funnel by showing your customers what they checked earlier.

A customer may keep checking other products and have difficulty in finding what they saw/liked earlier. However, a recently viewed product section helps them navigate back to what they saw earlier and purchase it.

Also, a visitor can compare the previously viewed products with new products to make an informed purchase decision. It enhances the shopping experience of your online store.

For Magento 2 store owners, one can add ‘recently viewed products’ from the admin panel as well as programmatically. You can configure it using the widget also to show recently viewed products in Magento 2.

Here, I’ve posted the method to programmatically display recently viewed products in Magento 2:

Method to Programmatically Display Recently Viewed Products in Magento 2

Use the below code in the catalog_product_view.xml in your layout folder.

The display will be:

How to Add Custom Field Below Apply Discount Code in Magento 2 Cart Page

Done!

Leverage the benefit of encouraging purchases by using the above method!

Any doubts? Do mention them in the Comments section below.

I would be glad to help you out.

Also, please share the solution with Magento Community via social media.

Thank you.

Get Weekly Updates

Never miss Magento tips, tricks, tutorials, and news.

Thank you for subscribing.

Something went wrong.

5
(based on 21 Reviews)

Krishna is a Magento developer at Meetanshi. She is always ready to learn new things. Apart from work, she likes to read books and spend time with family.

Leave a reply:

Your email address will not be published.