Bri*_*ian 5 navigation magento layered
我想按每个过滤器中的#项对每个分层导航过滤器进行排序.
以下是现在显示的内容 -
我要展示的内容 -
我一直在看目录/ layer/filter.phtml,但我无法弄清楚如何对magento集合进行排序.
理想情况下我想要这样的东西:
$ this-> getItems() - > order('Count Desc')
我怎么能做到这一点?
找到了做到这一点的方法 -
修改Mage/Catalog/Model/Layer/Filter/Abstract.php为使用getItems方法中的count重新排序.
public function getItems()
{
if (is_null($this->_items)) {
$this->_initItems();
}
//5-16-11 Custom sort
$items = $this->_items;
usort($items, array("Mage_Catalog_Model_Layer_Filter_Abstract", "sortByCount"));
return $items;
}
public static function sortByCount($a, $b)
{
if ($a->getCount() == $b->getCount()) {
return 0;
}
return ($a->getCount() > $b->getCount()) ? -1 : 1;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3843 次 |
| 最近记录: |