简体   繁体   中英

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.

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.

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.

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.

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

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

<?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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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