Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get recently viewed products array in Magento

Tags:

php

magento

I've got the problem that i have to highly customize a magento ecommerce shop. Therefore it would be great if i could have the data requested in

\app\design\frontend\avalanche\default\template\reports\product_viewed_details.phtml

via

$this->getRecentlyViewedProducts()




I already tried to get it via

Mage::getBlockSingleton('report/product_view')->getRecentlyViewedProducts();

, but the only thing i get is an empty array.


Could someone please help me? I'm driving a little bit crazy over here.

like image 410
chritaso Avatar asked Dec 04 '22 15:12

chritaso


2 Answers

Have you tried :

$collection = Mage::getSingleton('Mage_Reports_Block_Product_Viewed')->getItemsCollection();

like image 134
Fran Avatar answered Dec 07 '22 04:12

Fran


You can also use aliases, to produce more 'friendly' code:

$collection = Mage::getBlockSingleton('reports/product_viewed')->getItemsCollection();

like image 33
Kamil Szymański Avatar answered Dec 07 '22 04:12

Kamil Szymański