Sunday, May 5, 2013

Magento Module - Remove specific field from Catalog Filter

One of the common modification that most of client required was remove some fields from Magento catalog filter. Standard way for impalement above requirement Create new module and rewrite Catalog Layer View block. Hope following module will help you

app\code\local\kbtdeveloper\PriceFilterRemove\etc\config.xml


<?xml version="1.0" encoding="UTF-8"?>
<config>
    <global>
        <blocks>
            <catalog>
                <rewrite>
                    <layer_view>kbtdeveloper_PriceFilterRemove_Block_View</layer_view>
                </rewrite>
            </catalog>
        </blocks>
    </global>
</config>


\app\code\local\kbtdeveloper\PriceFilterRemove\Block\View.php



<?php

class kbtdeveloper_PriceFilterRemove_Block_View extends Mage_Catalog_Block_Layer_View {

    public function getFilters() {
        $filters = array();
        if ($categoryFilter = $this->_getCategoryFilter()) {
            $filters[] = $categoryFilter;
        }

        $filterableAttributes = $this->_getFilterableAttributes();
        foreach ($filterableAttributes as $attribute) {
        /**
        *Remove Price on Refine by block , store wise
        */
            if (Mage::app()->getStore()->getCode() == 'default') {
                if ($attribute->getAttributeCode() == 'price') {
                    continue;
                }
            }
            $filters[] = $this->getChild($attribute->getAttributeCode() . '_filter');
        }

        return $filters;
    }

}

No comments:

Post a Comment