Magento

Display Most Viewed Products In Magneto.

hello Friends today I will give some solution about Display Most Viewed Products In Magneto.

You can use this code any .phtml or .php files of Magento.

<?php
$storeId = Mage::app()->getStore()->getId();
$products_list = Mage::getResourceModel('reports/product_collection')
	->addAttributeToSelect('*')
	->setStoreId($storeId)
	->addStoreFilter($storeId)
	->addViewsCount();
print"<pre>";
foreach ($products_list as $product)
{
	echo "product Views : ". $product['views'];
	print_r($product);
}
?>

We create an object of the Mage::getResourceModel(‘reports/product_collection’) and filter out the data.

Hope you get the proper solution.

Advertisements

Leave your comments

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s