Hide or remove "category" filter from the layered navigation
Based on stackexchange.com answer:
If you want to do it via XML you should edit catalog.xml
replace:
<block type="catalog/layer_view" name="catalog.leftnav"
after="currency" template="catalog/layer/view.phtml" />
with this:
<block type="catalog/layer_view" name="catalog.leftnav" after="currency" template="catalog/layer/view.phtml">
<action method="unsetChild"><alias>category_filter</alias></action>
</block>
Try this code first. Here we are trying to remove this via layout xml update
File : app/design/frontend/<package>/<theme>/layout/local.xml
<layout>
<catalog_category_layered>
<reference name="catalog.leftnav">
<action method="unsetChild"><alias>category_filter</alias></action>
</reference>
</catalog_category_layered>
</layout>
This will solve your problem.
If it didn't worked, then you need to do a block rewrite. For this you need to create a module. The block that you need to rewrite is Mage_Catalog_Block_Layer_View
.
Module's activation file looks like this
File : app/etc/modules/Avoid_CategoryFromLN.xml
<config>
<modules>
<Avoid_CategoryFromLN>
<active>true</active>
<codePool>local</codePool>
</Avoid_CategoryFromLN>
</modules>
</config>
This is how rewrite configuration looks like
File : app\code\local\Avoid/CategoryFromLN/etc/config.xml
<config>
<modules>
<Avoid_CategoryFromLN>
<version>1.0.0</version>
</Avoid_CategoryFromLN>
</modules>
<global>
<blocks>
<catalog>
<rewrite>
<layer_view>Avoid_CategoryFromLN_Block_Layer_View</layer_view>
</rewrite>
</catalog>
</blocks>
</global>
</config>
Now your rewrite block should posses this content
File : app\code\local\Avoid/CategoryFromLN/Block/Layer/View.php
<?php
class Avoid_CategoryFromLN_Block_Layer_View exteds Mage_Catalog_Block_Layer_View
{
public function getFilters()
{
$filterableAttributes = $this->_getFilterableAttributes();
foreach ($filterableAttributes as $attribute) {
$filters[] = $this->getChild($attribute->getAttributeCode() . '_filter');
}
return $filters;
}
}
Here getFilters()
is the method that actually includes category filters inside layered navigation filter. We just remove that code by rewriting the core class. That's it.
Big Note: : You should keep capital letters as it is. Dont make them small letters. If you do, it will not work. Magento is strict in these things :) So revise all folder names, file names multiple times. Make sure you keep all names contents as it is
Now try again.
I will post down what it worked for me as a reference for others
adding this :
<reference name="catalog.leftnav">
<action method="unsetChild"><alias>category_filter</alias></action>
</reference>
in the custom design tab of every categories does the trick.
Remember especially to add it in the parent category, thats what did it for me.