tags:

views:

41

answers:

1

So I'm getting more and more familiar with the layered navigation Magento employs, and I do notice that it's possible to get various attributes of the items, like Name or a string Value, however there's one attribute I cannot get easily from the model I'm using ('catalog/layer_filter_item'): position.

Does anyone know how to get the position of the attribute filtering option, like say there's a color Magenta with a position of 2 -- how can I get that 2?

The question could also be -- how do I get the sort_order out of the table eav_attribute_option... if that helps.

Thanks for any help :)

A: 

It must be possible to modify the SQL generated by the filter's resource and so cause the value to be returned as a SELECT column. However that sounds hard so instead in the template (template/catalog/layer/filter.phtml) where you see this:

foreach ($this->getItems() as $_item)

Change it to:

foreach ($this->getItems() as $_idx => $_item)

And $_idx will be a number that increases along with sort_order. It will not be exactly the same, the keys of an array are zero-based and contiguous. If you gave positions of 1, 3 & 10 it would still come out as 0, 1, 2.

I admit it's a compromise but might just be good enough for your purposes.

clockworkgeek