Reputation: 449
How can i get total number of views of a product in magento i tried $fromDate = '2010-01-01'; $toDate = now();
$viewedProducts = Mage::getResourceModel('reports/product_collection')
->addViewsCount($fromDate, $toDate);
foreach($viewedProducts as $product) {
echo "ID: " . $product->getData('entity_id') . " - View Count: " . $product- >getData('views') . "<br/>";}
Upvotes: 0
Views: 1532
Reputation: 536
<?php
$id=$_helper->productAttribute($_product, $_product->getId(), 'id');
$fromDate = '2013-12-10';
$toDate = now();
$viewedProducts = Mage::getResourceModel('reports/product_collection')->addViewsCount($fromDate, $toDate);
foreach($viewedProducts as $product) {
if($product->getData('entity_id')==$id)
{
echo "Total View Count: " . $product->getData('views');
}}
?>
Upvotes: 1