Show product view count in product page in magento
add below line of code in view page:-
app/design/frontend/default/your theme/template/catalog/product/view.phtml
<?php
$id = $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');
}}
?>
You are done!!!!
add below line of code in view page:-
app/design/frontend/default/your theme/template/catalog/product/view.phtml
<?php
$id = $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');
}}
?>
You are done!!!!
No comments:
Post a Comment