:::: MENU ::::

Magento Tutorial | Magento Blog | Learn Magento 2

Cookies Consent Popup

If you are planning to add Recently Viewed products to your website then always use default magento approach. below approach is deprecated.


Because its not fully compatible with FPC so,now days magento using knockoutJS for Recently Viewed products. If you need to add a 'Recently Viewed' products block specifically via layout xml, use the same class Magento\Catalog\Block\Widget\RecentlyViewed which the 'Recently Viewed' Product widget uses.




This will render a simple grid with the last 4 products view by the user.
You can configure the block further, just as you would the widget instance:



One thing to note is that the argument values for ```show_attributes``` and ```show_buttons``` need to be declared as comma delimited strings (no spaces).
Declaring them as arrays or including spaces next to your comma's won't work due to the way the UI Component parse the content before Knockout renders it.
And since I said Knockout... it should play nicely with FPC, should.
Finally this solution doesn't use the **'action'** instruction which appears to have been deprecated.

That's it. Happy Coding !!!

0 comments:

Post a Comment