Hello Readers, Here is a small example which will explain how to show product views count in magento.
Add below line of code in view page:
Path: app/design/frontend/default/currentheme/template/catalog/product/view.phtml
<?php
$id = $id=$_helper->productAttribute($_product, $_product->getId(), 'id');
$fromDate = '2016-03-16';
$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');
}}
?>
Above code will get total number of views of product in magento from '2016-03-016' to now.
0 Comment(s)