Silahkan Melihat Tutorial di website kami dengan nyaman ENJOY YOUR LIFE ☕

Magento Category Product Listing Sort by Most Viewed Product

Hello,

You Just want to orverride app\code\core\Mage\Catalog\Block\Product\List\Toolbar.php

paste in code\local\Mage\Catalog\Block\Product\List\Toolbar.php


here 


first add your most viewed in sort by product select box


 public function getAvailableOrders()

    {

       $this->addOrderToAvailableOrders('mostviewd', 'MOST POPULAR');

        return $this->_availableOrder;\\you can add this code here
    }


 public function setCollection($collection)

    {

if ($this->getCurrentOrder()) {

               if($this->getCurrentOrder()=='mostviewd') {
              $this->_collection->getSelect()->
joinInner('report_event AS _table_views',
' _table_views.object_id = e.entity_id',
'COUNT(_table_views.event_id) AS views')->
group('e.entity_id')->order('views DESC');
       
    
            }

}


}

add this code and check the result.






0 komentar:

Post a Comment

Magento Category Product Listing Sort by Most Viewed Product