Basically Magento attribute
option takes database
order by default if we provide position it will shows based on that order. Like below
color: blue
green
black
size: s
xl
M
housing: 9
5
99
10
bold
ancle
raise
home
Like this I created Option same way it will in front end layered navigation
But my requirement is need to show in front end like below
color: black
blue
green
size: m
s
xl
housing: 5
9
10
99
ancle
bold
home
raise
like this I need I don't want to provide position for every attribute option
because I have lot of options having some attributes, so I am planing to display alphabetically, how admin created I don't care.
If anyone knows please help me where to change this order
Best Answer
Sorting can be done at the template level, but my preference would be to handle this in the block level.
To get to the right place, start at the template, like here:
The call chain looks like this:
So from the template we end up in
Mage_Catalog_Model_Layer_Filter_Abstract::_initItems
:We can see how they are generated, using method
$this->_createItem
. This is the perfect point to inject our override. But on an abstract class, we can't quite get to it without a core/local pool replacement (not ideal).Suggested Solution
catalog/block_layer_filter_attribute
getItems
on your rewrite classSo my class might look like this:
I should note that this only applies to the generic attribute filter. Magento implements custom filters also for price, decimal, and category types. If you need to sort options on those, too, then create additional block rewrites to sort in a similar way.