首页 文章

如何将制造商属性添加到过滤结果中的magento分层导航

提问于
浏览
0

我正在使用Magento企业版,默认情况下我在左侧导航栏中显示类别和价格范围,同时按类别显示产品列表 .

但是,我需要添加其他产品属性,如制造商,传输类型...到过滤器结果分层导航 .

我可以在该制造商属性下显示制造商列表,但选项“过滤无结果”为0计数 .

每当我在管理员端将制造商属性的选项更改为 'Filter with results' Catalogue/Attributes/Manage Attributes 时,我无法在前端左侧导航栏中看到该属性 .

即使有很多产品与制造商分配 . 我是否需要在Code中进行任何更改,请帮助我,我是这个magento平台的新手 .

谢谢

2 回答

  • 1

    对不起,如果听起来是一个愚蠢的问题,但你改变了看到类别配置锚定在YES?

    我会在答案后告诉你

    最好的,亚历杭德罗

  • 0

    在您的:magento / app / code / core / Mage / Catalog / Block / Navigation.php中添加此功能

    public function getAllManu()
     {
            $product = Mage::getModel('catalog/product');
            $attributes = Mage::getResourceModel('eav/entity_attribute_collection')
            ->setEntityTypeFilter($product->getResource()->getTypeId())
                    ->addFieldToFilter('attribute_code', 'manufacturer'); //can be changed to any attribute
            $attribute = $attributes->getFirstItem()->setEntity($product->getResource());
            $manufacturers = $attribute->getSource()->getAllOptions(false);
    
            return $manufacturers;
        }
    

    现在在位置添加phtml文件:magento / app / design / frontend / mytheme / default / template / catalog / navigation / left_nav.phtml

    <?php foreach ($this->getAllManu() as $manufacturer): ?>
                    <li>
                        <a href="catalogsearch/advanced/result/?manufacturer[]=<?php echo $manufacturer['value'] ?>"><?php echo $manufacturer['label'] ?></a>
                    </li>
    <?php endforeach;?>
    

    只需调用block:magento / app / design / frontend / mytheme / default / layout / catalog.xml

    <reference name="left">
                <block type="catalog/navigation" name="catalog.leftnavigation" template="catalog/navigation/left_nav.phtml"/>
    </reference>
    

相关问题