Is it possible to configure the recently viewed products widget to show the products that all visitors have recently viewed? The regular widget only shows the products which you have viewed yourself.
Magento – Recently viewed products from all users
ce-1.4.1.1productwidgets
Related Solutions
Unfortunately the accepted answer didn't work for me and I wasn't able to use widget instance layout updates in my use case
If for whatever reason you need to add a 'Recently Viewed' products block specifically via layout xml, here's my solution (tested in version 2.2.2):
I decided to use the same class Magento\Catalog\Block\Widget\RecentlyViewed
which the 'Recently Viewed' Product widget uses in my block declaration.
<!-- Basic recently viewed products block -->
<block class="Magento\Catalog\Block\Widget\RecentlyViewed" name="recently_viewed" template="Magento_Catalog::product/widget/viewed/grid.phtml" after="-">
<arguments>
<argument name="uiComponent" xsi:type="string">widget_recently_viewed</argument>
<argument name="page_size" xsi:type="number">4</argument>
</arguments>
</block>
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:
<!-- Configured recently viewed products block -->
<block class="Magento\Catalog\Block\Widget\RecentlyViewed" name="recently_viewed" template="Magento_Catalog::product/widget/viewed/grid.phtml" after="-">
<arguments>
<argument name="uiComponent" xsi:type="string">widget_recently_viewed</argument>
<argument name="page_size" xsi:type="number">4</argument>
<!-- 'Product attributes to show' configuration -->
<argument name="show_attributes" xsi:type="string">name,image,price,learn_more</argument>
<!-- 'Buttons to show' configuration -->
<argument name="show_buttons" xsi:type="string">add_to_cart,add_to_compare,add_to_wishlist</argument>
</arguments>
</block>
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
Best Answer
Checking the block class outputting the recently viewed products
Mage_Reports_Block_Product_Viewed
you can see the_toHtml
method uses thegetItemsCollection
method fromMage_Reports_Block_Product_Abstract
.In this class the collection is actually retrieved and on line 124 the customer ID is added to the collection as a filtering.
So a good place to start would be to rewrite the
Mage_Reports_Block_Product_Abstract
to a custom extension and modify the collection retrieval excluding the customer filter.Optionally you could copy this file to local and modify it but that might lead to issues when upgrading to a newer version of Magento (and is also just a bad practice in general)