I'm getting so mad that it literally hurts with a problem related to attribute option collection on Magento 1.8.1
I have a dropdown type attribute populated with dozens of values and frequently updated with new values, wich is used for layered navigation purposes.
What im trying to do is actually change de default behaviour and sort NUMERICALLY all theese options if "position" is not set.
Magento sorts my values like this (alphabetically)
100 Watt
1000 Watt
1200 Watt
200 Watt
300 Watt
I need to sort them this way
100 Watt
200 Watt
300 Watt
1000 Watt
1200 Watt
I tried to edit class Mage_Eav_Model_Resource_Entity_Attribute_Option_Collection in any way.
Maybe i'm pretty close adding in public function setStoreFilter
$this->getSelect()->reset(Zend_Db_Select::ORDER);
$this->getSelect()->order(new Zend_Db_Expr("CAST('value' AS SIGNED) ASC"));
Hope someone can help me understand how to achieve this.
CAST
. Although you would probably need to strip the "Watt" text withREPLACE
dev.mysql.com/doc/refman/5.0/en/… before you try to cast it.