<div class="count-product">
    <?php
        $id = $id=$_helper->productAttribute($_product, $_product->getId(), 'id');
        $mostviewedProducts = Mage::getResourceModel('reports/product_collection')->addViewsCount();
         foreach($mostviewedProducts as $product) {
            if($product->getData('entity_id')==$id)
            {
                //echo $id."<br/>";
                //echo $_product->getId()."<br/>";
                //echo $product->getData('entity_id')."<br/>";
                echo "Total View Count: " . $product->getData('views');
            }
         }
    ?>
</div>

You can add time duration in

$fromDate = ‘2013-12-10’;
$toDate = now();

$mostviewedProducts = Mage::getResourceModel('reports/product_collection')->addViewsCount($fromDate,$toDate);

Categories: Magento

0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *