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
So I found a thread on this on their documentation, and apparently it's a known pain point for the product. The best solution I found was to override the ORDER BY
for the query by calling a primitive method of the Collection
class, here's the example they give:
$_productCollection = Mage::getModel('catalog/product')->getCollection();
$_productCollection->setOrder(array('cm_brand', 'name', 'cm_length'), 'asc');
$_productCollection->getSelect()->reset(Zend_Db_Select::ORDER);
$_productCollection->getSelect()->order(array('cm_brand ASC', 'name ASC', 'CAST(`cm_length` AS SIGNED) ASC'));
Based on your example with only one sorting column, I would think you could go with:
$_productCollection = Mage::getModel('catalog/product')->getCollection();
$_productCollection->setOrder('weight', 'asc');
$_productCollection->getSelect()->reset(Zend_Db_Select::ORDER);
$_productCollection->getSelect()->order('CAST(`weight` AS SIGNED) ASC'));