- $products = Mage::getModel(‘catalog/product’) ->getCollection() ->addAttributeToSelect(‘*’) ->addAttributeToSort(‘position’, ‘ASC’); ->load();
- $products = Mage::getModel(‘catalog/product’) ->getCollection() ->addAttributeToSelect(‘*’) ->addOrder(‘position’, ‘ASC’); ->load();
- function cmp($a, $b) { if ($a == $b) { return 0; } return ($a < $b) ? -1 : 1; } $products = Mage::getModel(‘catalog/product’) ->getCollection() ->addAttributeToSelect(‘*’) ->load(); usort($products, “cmp”);
function mySortByPosition($a, $b) { if ($a[‘position’] == $b[‘position’]) { return 0; } return ($a[‘position’] < $b[‘position’]) ? -1 : 1; } $products = Mage::getModel(‘catalog/product’) ->getCollection() ->addAttributeToSelect(‘*’) ->addSorter(mySortByPosition) ->load();