【问题标题】:Magento 1.7 left navigation category sort order alphabeticallyMagento 1.7 左侧导航类别按字母顺序排序
【发布时间】:2013-12-30 05:14:44
【问题描述】:

我想知道如何更改父类别页面左侧边栏上列出的子类别的排序顺序(例如:“品牌”页面的左侧菜单项按 ID 顺序列出子类别名称,而不是按字母顺序按名字)。我尝试修改 leftnav.phtml 文件,但似乎无法弄清楚如何将名称拉入数组以对其进行排序。

【问题讨论】:

    标签: arrays navigation magento-1.7 categories


    【解决方案1】:

    这是我用来按字母顺序排列所有父子类别的方法...希望对您有所帮助

    SET @i=0;
    SET @j=0;
    DROP TABLE IF EXISTS AAA_NEW_POSITION;
    CREATE TABLE AAA_NEW_POSITION                
    SELECT
    e.entity_id AS 'entity_id',
    vn.value AS 'name',
    e.position AS 'old_position', @i:=@i+1 AS 'new_position'
    FROM
    catalog_category_entity e
    LEFT JOIN catalog_category_entity_varchar vn
    ON e.entity_id = vn.entity_id AND
    vn.attribute_id = (SELECT attribute_id FROM
    eav_attribute WHERE entity_type_id = (SELECT entity_type_id FROM catalog_category_entity LIMIT 1) AND attribute_code='name')
    ORDER BY vn.value ASC;
    
    ALTER TABLE AAA_NEW_POSITION ORDER BY NAME;
    UPDATE AAA_NEW_POSITION SET new_position= @j:=@j+1 ORDER BY NAME;
    
    UPDATE catalog_category_entity e
    LEFT JOIN AAA_NEW_POSITION np
    ON e.entity_id = np.entity_id
    SET e.position = np.new_position;
    
    DROP TABLE IF EXISTS AAA_NEW_POSITION; 
    

    【讨论】:

      【解决方案2】:

      这篇文章很旧,但永远不会回答。希望它会帮助某人

      覆盖下面的文件

      app/code/core/Mage/Catalog/Model/Layer/Filter/Abstract.php
      

      app/code/local/Mage/Catalog/Model/Layer/Filter/Abstract.php
      

      替换

      return $this->_items;
      

      asort($this->_items);
      return $this->_items;
      

      就是这样,您将按字母顺序获得所有左侧导航项。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2010-10-07
        • 2012-11-08
        • 1970-01-01
        相关资源
        最近更新 更多