So I\'ve Googled like crazy to try and find a solution to this problem that actually works properly but have come up empty handed.
When using the Sort By function on a
In response to Adam B's post.
My situation: I needed to sort products by a custom Magento (1.8.1.0) attribute with a numerical value. However, Magento was sorting like:
1 , 11 , 123 ,2 ,234, 3
(alphanumerical)
instead of: 1, 2, 3, 11, 123, 234
(numerical)
I honestly don't get why this is not working out of the box but I got this working with the following adaption:
$this->_productCollection->getSelect()->order(new Zend_Db_Expr("CAST( ".$filterAttribute." AS SIGNED ) ".$filterAttributeDir));
Hope it's to any use for someone.