Thanks for your reply, Anuj, it was the best work module that I could find so far.
Just add an extra bit to your code to prevent paging caused by 'group by'
Copy '/lib/varien/data/collection/Db.php' to "local / varien / data / collection / Db.php".
Change getSize function to
public function getSize() { if (is_null($this->_totalRecords)) { $sql = $this->getSelectCountSql(); //$this->_totalRecords = $this->getConnection()->fetchOne($sql, $this->_bindParams); //============================>change behave of fetchOne to fetchAll //got array of all COUNT(DISTINCT e.entity_id), then sum $result = $this->getConnection()->fetchAll($sql, $this->_bindParams); foreach ($result as $row) {//echo'<pre>'; print_r($row); $this->_totalRecords += reset($row); } } return intval($this->_totalRecords); }
Hope this can help anyone.
update It is also necessary to update the filter section, otherwise just show 1 element on the entire filter. and the price filter will not be accurate.
What do you need to do to change core / mage / catalog / model / layer / filter / attribute.php and price.php
attribute.php getCount () at the bottom
$countArr = array(); //print_r($connection->fetchall($select)); foreach ($connection->fetchall($select) as $single) { if (isset($countArr[$single['value']])) { $countArr[$single['value']] += $single['count']; } else { $countArr[$single['value']] = $single['count']; } } //print_r($countArr);//exit; return $countArr; //return $connection->fetchPairs($select);
Price.php getMaxPrice
$maxPrice = 0; foreach ($connection->fetchall($select) as $value) { if (reset($value) > $maxPrice) { $maxPrice = reset($value); } } return $maxPrice;
If you have the same problem and are looking for a question, you will understand what I had in mind. Good luck, spent 8 hours on this best selling feature.
Refresh again,
just found a different implementation method using cron to collect the best sales data stored daily in a table that includes product_id and the calculated base sales figure. itβs just a left join, without using 'group by', this means that the main functions do not need to change and speed up the entire sorting process. Finally finished! hehe