1

I need to change my attribute selection as a drop down instead list. User can manually click what they are need to be applied filter of products.

Attribute List :

enter image description here

0

The block you are asking to change is a price filter block, of type Mage_Catalog_Block_Layer_Filter_Price.

It extends the Mage_Catalog_Block_Layer_Filter_Abstract and the phtml template is assigned in the __construct() method to catalog/layer/filter.phtml.

If you want to customize the price filter you have different options:

  • perform a block rewrite, use your own block which extends Mage_Catalog_Block_Layer_Filter_Price and assign your own template in the __construct() method; I discourage this approach;
  • add a layout rule which changes the template of the price filter block; this is the approach I prefer so I explain it below.

To change the template we need to reference the price filter block by its name in layout; the problem is that the price filter block has a dynamic layout name.

It has the fixed alias price_filter but it can only be used to retrieve a child from a parent block; the parent block has catalog.leftnav fixed name in layout so with the following snippet placed at the bottom of the index.php we'll retrieve the price filter name in layout (from a layered category page):

$layout = Mage::app()->getLayout();
$leftNav = $layout->getBlock('catalog.leftnav');
if ($leftNav) {
    $priceFilter = $leftNav->getChild('price_filter');
    if ($priceFilter) {
        var_dump($priceFilter->getNameInLayout());
    }
}

Warning: this means "touching the core" so restore the original index.php as soon as you have retrieved the price filter block name.

In my case the price filter block name is catalog.leftnav.child2 so I can use this name to add a layout rule as follows:

<layout>
    <catalog_category_layered>
        <reference name="catalog.leftnav.child2">
            <action method="setTemplate">
                <template>[custom_template_path]</template>
            </action>
        </reference>
    </catalog_category_layered>
</layout>    

To build your custom template, start from catalog/layer/filter.phtml.

Hope it helps.

  • the simplest way I didn't think to is that of changing the catalog/layer/filter.phtml file of your custom template – Alessandro Ronchi Sep 10 '16 at 7:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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