Sunday, 13 September 2015

Get Most view products of current product categories in product detail page(view.phtml) in magento


Here Qurery for Create Most View product of current product of categories

This Section Query used Most view Product view in magento. it's difficult to get because

I am seaching but to get proper result. after i get solution from different different reference

site. i am will give proper guide for that. it success to use it.

    $storeId = Mage::app()->getStore()->getId();
            $category_ids = $_product->getCategoryIds();
            /** date range product view count */
            $toDate   = now();
           $product_id = Mage::registry('current_product')->getId();

$products = Mage::getResourceModel('reports/product_collection')
    ->setPageSize(5)//set the pae size
    ->addAttributeToFilter('category_id', array('in' => $category_ids ));


here one problem you face if current product detail page in this section then you have

I have issue when I go to  section on product detail page; the current product is also getting displayed on this. I just need to remove the current product from  section.

it's soultion is that without change query

foreach($products as $_item){

    $myid =  $_item->getId();

    if ($myid !=  $product_id ){

<?php echo $_item->getProductUrl() ?>



No comments:

Post a Comment

Thank You For Comment