0

我希望修改默认的 Magento (1.6) 目录排序以添加按产品实体 ID 排序的选项,然后将其设为默认排序。

(在 StackOverflow 和 Google 上进行了搜索,但只能找到适用于旧 Magento 版本或编辑核心文件的解决方案。)

提前致谢!

4

2 回答 2

1

这个http://blog.chapagain.com.np/magento-join-filter-select-and-sort-attributes-fields-and-tables/是一篇很好的文章,它提供了有关如何过滤和排序集合的信息。

于 2012-07-01T16:33:08.677 回答
0

在不更改任何核心文件的情况下进行此操作的最佳方法是复制位于以下位置的 Toolbar.php 文件:

/app/code/core/Mage/Catalog/Block/Product/List/Toolbar.php

然后在下面创建一个新的目录路径(如果你还没有创建一个):

/app/code/local/Mage/Catalog/Block/Product/List/Toolbar.php

现在从第 232 行替换以下内容:

    if ($this->getCurrentOrder()) {
        $this->_collection->setOrder($this->getCurrentOrder(), $this->getCurrentDirection());
    }

if ($this->getCurrentOrder()) {
if(($this->getCurrentOrder())=='position'){ //defines the sort option
//sort by entity_id (descending)
$this->_collection->addAttributeToSort('entity_id','desc');
} else {
$this->_collection->setOrder($this->getCurrentOrder(),$this->getCurrentDirection());
}
}

最后,在您的 Magento 后端重新索引和刷新缓存并准备就绪。

于 2015-10-22T13:20:44.933 回答