Magento: Display The Filterable Attributes In A Drop-down Menu in Layered Navigation

In this article I'll discuss about the Filterable Attribute in drop down format in Layered navigation in Magnto.

For this you have to follow below steps:-

1. Find the following folder location under app/design/frontend/package/theme/template/catalog/layer.

2. Go to the filter.phtml and replace the code with the following code:

[php]
<?php

//either dropdown list or default method (ordered list)
$attributeName = $this->getName();//Get the atrribute name
$itemcountthreshold = 1; // you can change
$itemcount = $this->getItemsCount();//Get the number of items under each subcategories
$displayitemcount = true; //set to true/false to display item count in brackets

//check if the items under a subcategory greater than the number of items count you specified.
if($itemcount > $itemcountthreshold){
$attributeName = "Overthreshold";
}

//Make the atrributes to appear in a list format
if(!function_exists("_displayOrderedlist")){
function _displayOrderedlist($atts,$displayitemcount){
echo '<ol>';
foreach($atts->getItems() as $_item){
echo '<li><a href="'.$_item->getUrl().'">'.$_item->getLabel().'</a>';
if($displayitemcount){
echo ' ('.$_item->getCount().')';
}
echo '</li>';
}
echo '</ol>';
}
}

//Make the atrributes to appear in a Dropdown format.
if(!function_exists("_displayDropdown"))
{
function _displayDropdown($atts,$displayitemcount)
{
echo '<select id="layered-select" class="select" name="layered-select"
onchange="if (this.selectedIndex > 0) location.href=this[this.selectedIndex].value;">';
echo '<option selected="selected">Please select</option>';
foreach ($atts->getItems() as $_item)
{
echo '<option value="'.$_item->getUrl().'">';
echo $_item->getLabel();
if($displayitemcount)
{
echo ' ('.$_item->getCount().')';
}
echo '</option>';
}
echo '</select>';
}
}

switch ($attributeName)
{
case 'Overthreshold':
_displayDropdown($this,$displayitemcount);
break;

default:
_displayOrderedlist($this,$displayitemcount);
break;
}

?>
[/php]