I've been trying lots of methods to achieve but none worked. Please give me a 开发者_运维问答hint how to to this.
I need to use a sort by sku on products that appear on an order print.
$order = Mage::getModel('sales/order')->load($order)
this is $order collection and a few lines below I have:
foreach ($order->getAllItems() as $item) { ... }
I need the sort to be applied on getAllItems before showing, obviously.
I hope I was clear enough, if not ask.
you might have already solved, but I will answer this for people having the same problem:
$oItems = $oOrder->getItemsCollection()->addAttributeToSort('price_incl_tax', 'DESC');
$aItems = array();
foreach ($oItems as $oItem) {
if (!$oItem->isDeleted()) {
$aItems[] = $oItem;
}
}
Hope this helps anyone.
精彩评论