简体   繁体   English

如何在Magento分层导航中将Manufacturer属性添加到Filter结果

[英]How to add Manufacturer attribute to Filter results in magento layered navigation

I'm working with Magento Enterprise edition, here by default I'm getting Category's and Price ranges in left navigation bar while displaying products list by Category. 我正在使用Magento企业版,默认情况下,在按类别显示产品列表时,在左侧导航栏中会获得类别和价格范围。

But, I need to add other product attributes like Manufacturer, Transfer type... to the filter results in layered navigation. 但是,我需要将其他产品属性(例如制造商,转移类型...)添加到分层导航的过滤结果中。

I'm able to display that list of Manufacturers under that Manufacturer Attribute but with option 'Filter with no results' with 0 count. 我可以在“制造商属性”下显示该制造商列表,但带有“无结果过滤”选项,且计数为0。

Whenever I changed that option in Admin side for Manufacturer Attribute as 'Filter with results' under Catalogue/Attributes/Manage Attributes I'm unable to see that attribute in front end left navigation bar. 每当我在Catalogue/Attributes/Manage Attributes下将'Filter with results'制造商属性'Filter with results'管理”中的选项更改为“制造商属性'Filter with results'无法在前端左侧导航栏中看到该属性。

Even though there is assigned lot of products with Manufacturer's. 即使为制造商分配了很多产品。 Do i need to make any changes in Code, please help me out I'm new to this magento platform. 我是否需要对Code进行任何更改,请帮助我,我是这个magento平台的新手。

Thanks 谢谢

Sorry if sound a stupid question but you changed see the category configuration to be anchor in YES? 抱歉,如果您听到的是一个愚蠢的问题,但是您更改了,将类别配置固定为是?

I'll keeping you posted after the answer 回答之后,我会及时通知你

Best, Alejandro 最好,亚历杭德罗

add this function in your: magento/app/code/core/Mage/Catalog/Block/Navigation.php 在您的以下位置添加此功能: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;
    }

Now add phtml file at location: magento/app/design/frontend/mytheme/default/template/catalog/navigation/left_nav.phtml 现在在以下位置添加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;?>

And simply call block:magento/app/design/frontend/mytheme/default/layout/catalog.xml 然后只需调用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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM