Magento attributes sort order (position) can be set on the attribute level using the element Position of attribute in layered navigation block
.
We have some categories that are built bassed on a specific attribute. Normally size is the 6tc position/order of atrtibute filters in layered navigation.
For one category I would like to move the "Position of attribute in layered navigation block" to say position 1 (top).
Question: can this be done via a category layout update?
thanks, Sean
Best Answer
Not without custom code. There is a block class for the filter display,
Mage_Catalog_Block_Layer_State
, but the filter data comes from the modelMage_Catalog_Model_Layer_State
, which is populated byMage_Catalog_Model_Layer
and cannot be influenced from the block.If your alternative sort order can be expressed with an SQL order clause, you could override
Mage_Catalog_Model_Layer::_prepareAttributeCollection()
and change the sort order of the collection depending on the current category. It's set to$collection->setOrder('position', 'ASC')
before this method is called. But rewriting the layout model is better avoided.A better option without rewrites is to create a custom block that extends
Mage_Catalog_Block_Layer_State
:And another one that extends
Mage_Catalog_Block_Layer_View
because this is where the state block is created:Then replace the layer block in your categories custom layout update:
It's adding a new block, but using the same name
catalog.leftnav
of the original block, so it will be replaced. This is because you cannot change the type of an existing block.