我想默认从最新到最旧显示我的所有产品。我看到了这个链接:
还有this一个。所有这些都显示相同的解决方案,但总是为Frontend。
我想要的是默认设置系统 - >配置 - >目录 - >产品列表按排序,并默认设置为创建 ,我也想设置顺序(desc或asc)。
有关如何自定义的任何想法?
答案 0 :(得分:3)
对不起,我没有回答你的问题。
网格按entity_id排序:
// app/code/core/Mage/Adminhtml/Block/Catalog/Product/Grid.php:41
$this->setDefaultSort('entity_id');
$this->setDefaultDir('DESC');
这意味着,您想要的行为应该是默认行为。
答案 1 :(得分:2)
您可以安装GridControl并编写扩展名并将其添加到您在模块中创建的grid.xml
<?xml version="1.0"?>
<gridcontrol>
<grids>
<product.grid>
<add>
<header>Created at</header>
<type>int</type>
<index>created_at</index>
</add>
</product.grid>
</grids>
</gridcontrol>
此解决方案未经过测试。
答案 2 :(得分: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 position (ascending) and entity_id (descending)
$this->_collection->addAttributeToSort('position','asc')->addAttributeToSort('entity_id','desc');
} else {
$this->_collection->setOrder($this->getCurrentOrder(),$this->getCurrentDirection());
}
}
最后,重新索引并刷新Magento后端的缓存并准备就绪。