【问题标题】:Sort products by 2 attributes in magento catal在magento catal中按2个属性对产品进行排序
【发布时间】:2011-02-04 17:04:25
【问题描述】:

在我的 magento 网站上,我们需要按 2 个属性“制造商”、“名称”对产品列表进行排序,然后返回到唯一和默认属性“实体 ID”。

似乎 magento 只允许您按 1 排序,然后按 entity_id 排序。如果需要,我不介意以一种 hacky 方式执行此操作。

环顾四周有几个人有问题,但似乎没有人提供答案,所以我想我会在之前给出这个问题(第一个问题也是,必须是一个顽固的人:))。

http://www.magentocommerce.com/boards/viewthread/7314/

http://www.magentocommerce.com/boards/viewthread/206869/

【问题讨论】:

    标签: sql magento e-commerce magento-1.4


    【解决方案1】:

    经过一些研究(我不是 php 开发人员 =/),以下似乎可行:

    setOrder() 方法接受一个数组。

    $Collection->setOrder(array('attribute1', 'attribute2'), asc);

    我不确定有人会如何使用它,但我在 Catalogue/Product/List/ 目录中的 Toolbar.php 中修改了这一行。

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

    所以我的所有收藏都按当前顺序(默认顺序)排序,然后硬编码为之后按名称排序。仍在对其进行一些测试,但似乎可以工作......

    【讨论】:

      猜你喜欢
      • 2014-06-09
      • 1970-01-01
      • 1970-01-01
      • 2011-10-27
      • 1970-01-01
      • 1970-01-01
      • 2015-12-31
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多