0

I've been using the recently viewed block on the majority of Magento 1 websites I've created and I always thought the recently block was unique to the current user (guest or registered).

A client has noticed the recently viewed block is showing random products and it's got me thinking the block is showing other customers recently viewed which would make it site wide instead of unique to the user.

Can anyone confirm whether it's unique or site wide as I cannot see any issues with the setup (v1.9.3.6).

0

Recently viewed products block is part of the Mage_Reports module.

Looking in the source code here : app/code/core/Mage/Reports/Block/Product/Abstract.php:137:

if ($this->getCustomerId()) {
    $this->_collection->setCustomerId($this->getCustomerId());
}

and here : app/code/core/Mage/Reports/Model/Resource/Product/Index/Collection/Abstract.php:121 :

if (Mage::getSingleton('customer/session')->isLoggedIn()) {
   $condition['customer_id'] = Mage::getSingleton('customer/session')->getCustomerId();
}

means that it should be unique for a logged in customer.

For a guest, this code (here again : app/code/core/Mage/Reports/Model/Resource/Product/Index/Collection/Abstract.php:126)

else {
   $condition['visitor_id'] = Mage::getSingleton('log/visitor')->getId();
}

seems indicate that it will be unique if the log feature is enabled.

Sometimes, the log feature is disabled (with some observer overload) to improve performance : maybe it could explain your issue in the guest case.

Sometimes, there is a full page cache feature added to the Magento 1 source code that could explain some issue even for a logged in customer.

Hope it helps.

1
  • Thanks for the breakdown, all makes sense. I can see the log's are enabled but I'll go and check if there is an observer or any other functionality over ridding this and let you know. Dec 16 '19 at 16:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.