【问题标题】:How to change category filter position in magento layer navigation如何在 magento 图层导航中更改类别过滤器位置
【发布时间】:2013-10-18 13:57:00
【问题描述】:

我正在使用 magento 1.7,

我在类别页面左侧边栏的图层中有四个过滤器。

它们被列为

分类品牌尺寸颜色。

我想更改类别和品牌位置我希望品牌首先定位如下。

品牌类别大小颜色。

我该怎么做

【问题讨论】:

    标签: magento magento-1.7


    【解决方案1】:

    在分层导航中使用的打开属性,并且有字段/文本框可以在前端属性下添加位置值。

    根据您的要求放置位置。

    然后也重新索引。

    如果要设置类别过滤器位置,请按照以下步骤操作:

    复制文件:app\code\core\Mage\Catalog\Block\Layer\View.php 粘贴文件:app\code\local\Mage\Catalog\Block\Layer\View.php

    然后更新app\code\local\Mage\Catalog\Block\Layer\View.php文件的代码。

    用下面的代码替换getFilters()功能代码:

    public function getFilters()
    {
        $filters = array();
        $catFilters = array(); // Created New array
        if ($categoryFilter = $this->_getCategoryFilter()) {
            $catFilters[] = $categoryFilter; // Assign category to new array
        }
    
        $filterableAttributes = $this->_getFilterableAttributes();
        foreach ($filterableAttributes as $attribute) {
            $filters[] = $this->getChild($attribute->getAttributeCode() . '_filter');
        }
    
        /* Pushed category filter array to position 1, if want to change position then update value in this function. */
        array_splice( $filters, 1, 0, $catFilters ); 
        return $filters;
    }
    

    希望对您有所帮助!

    【讨论】:

    • 您的解决方案对于属性过滤器是正确的,但类别不是属性。我已经添加了这个职位字段,但它不起作用。我无法为类别过滤器提供位置。
    • @user2293790,我已经更新了答案。按照以下步骤将类别过滤器放在所需位置。您需要将 Mage_Catalog_Block_Layer_View 块文件复制到本地目录,以免影响核心代码。
    猜你喜欢
    • 2014-07-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-04-03
    • 1970-01-01
    相关资源
    最近更新 更多