3

I'm trying to disable a particular attribute filter in layered navigation for a specific category. The attribute filter I wish to disable is the manufacturer in this instance.

I'm trying the following in the 'Custom Design Layout' for the category in question:-

<block type="catalog/layer_view" name="catalog.leftnav" after="currency" template="catalog/layer/view.phtml">
    <action method="unsetChild"><alias>manufacturer_filter</alias></action>
</block>

This is half working, it hides the manufacturer filter in the layered navigation, but it also hides everything else below this in catalog.leftnav.

Any idea how the above needs modifying to prevent that from happening?

To explain what I mean, here are screenshots.

Before the XML update

enter image description here

After the XML update

enter image description here

closed as too broad by Keyul Shah, Amit Bera, David Manners, Matthias Zeis, Moose Oct 29 '14 at 13:28

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • I don't understand this, what do you mean, by "but it also hides everything else below this in catalog.leftnav." – Fabian Blechschmidt Dec 6 '13 at 14:07
  • Everything else in the left hand sidebar below <alias>manufacturer_filter</alias> disappears from the page. – zigojacko Dec 6 '13 at 14:08
  • all other filter!? – Fabian Blechschmidt Dec 6 '13 at 14:11
  • No.... EVERYTHING - I don't know how else to explain it but absolutely everything below the particular filter disappears from the sidebar (everything above it stays, everything below it vanishes). It's like a syntax error or something and the element stops loading but there is nothing in the logs. – zigojacko Dec 6 '13 at 14:13
  • I can provide before/after screenshot if necessary. – zigojacko Dec 6 '13 at 14:14
6

You can achieve this if you rewrite the Mage_Catalog_Model_Layer::getFilterableAttributes method.
For a specific category you can add a new filter.

Something like this (not tested)

public function getFilterableAttributes()
{
    $setIds = $this->_getSetIds();
    if (!$setIds) {
        return array();
    }
    $collection = Mage::getResourceModel('catalog/product_attribute_collection');
    $collection
        ->setItemObjectClass('catalog/resource_eav_attribute')
        ->setAttributeSetFilter($setIds)
        ->addStoreLabel(Mage::app()->getStore()->getId())
        ->setOrder('position', 'ASC');
    if ($this->getCurrentCategory()->getId() == 7) {
         //if in that specific category...You can even make this a category setting or a config setting so you won't hard code it.  
         $collection->addFieldToFilter('attribute_code', array('neq'=>'manufacturer'));
    }

    $collection = $this->_prepareAttributeCollection($collection);
    $collection->load();

    return $collection;
}
  • Can't actually recall if we used this in the end but this looks a good way to define the available filters so accepting as the answer :) – zigojacko May 6 '15 at 10:20

Not the answer you're looking for? Browse other questions tagged or ask your own question.