Magento: ordinare un elenco di ordini

Per ordinare un elendo di ordini in Magento, si può usare il metodo:

addAttributeToSort($attributo, dir="asc");

Un esempio, che carica gli ordini ordinati per data di creazione:

Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
 
$orders = Mage::getModel('sales/order')->getCollection()
                ->addAttributeToSelect("*");
 
$orders->addAttributeToSort('created_at', $dir="desc");

testato con la versione 1.5.0.1.

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>