Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Magento product views count

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 528
    Comment on it

    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)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: