Magento1.6按产品id降序排列问题

作者:Jeen 发布于:2013-4-21 18:26 Sunday 分类:工作笔记

一般情况下,修改产品排列顺序

修改

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

文件即可

分类页按id升序排列    protected $_direction           = ‘asc’;
分类页按id降序排列    protected $_direction           = ‘desc’;

1.6版本 修改了之后 没反应

对比发现,默认样本数据在分类中的排序 (position) 值为0
而手动上传的产品默认排序(position)值为1
具体是不是由于这个导致的  没有去深究… :(

网上查了下,选择了 一个算是比较直接的解决办法
修改 app/code/core/Mage/Catalog/Block/Product/List.php  文件
_getProductCollection() 方法 末尾 添加如下代码

// sort by created_at date or entity_id
if(!isset($_GET['order'])) {
    $this->_productCollection->getSelect()->reset( Zend_Db_Select::ORDER );
    $this->_productCollection->getSelect()->order('e.entity_id desc');
}
return $this->_productCollection;

然后清理缓存即可

参考资料网址
(1) http://stackoverflow.com/questions/2237513/magento-sort-by-date-added
(附加)http://blog.chapagain.com.np/magento-join-filter-select-and-sort-attributes-fields-and-tables/

:-)

标签: magento

发表评论:

©2010-2024 Jeen All Rights Reserved.Powered by emlog 京ICP备15058100号-1