Below is my code but I can't fetch order items details,just I need order items from sales_order_grid_collection object,I also try getAllItems() but it does not work

This is my config.xml file


this is observer.php

public function customOrderGridCollection(Varien_Event_Observer $observer)
            $orderGridCollection = $observer->getOrderGridCollection();
            // $collection = $observer->getEvent()->getOrderGridCollection();
   foreach ($orderGridCollection as $order) 
    foreach ($order->getAllItems() as $item) //$order->getAllItems() not work 
        // $item->getData('product_id') not work 



2 Answers 2


As you have using Collection load_before event and using nested foreach loop that it have creating lot of time taken for execute the observer code.That make huge issue

My suggestion to avoid to multiple times order and order item load. Use this process getting the item data.

  • First get all order ids using ->getAllIds()


  • Then filter order item collection Mage::getResourceModel('sales/order_item_collection') by order ids


If you want all records of specific one column value then add getColumnValues($colName). Just like


  • Amit, I have one doubt. Collection would be available in load_before event ? Oct 9, 2015 at 5:23
  • rajeev.. i will get back to you shortly..
    – Amit Bera
    Oct 9, 2015 at 7:41

May be the event that you are listening is wrong. I think you should use sales_order_grid_collection_load_after in this case. Because sales_order_grid_collection_load_before is an event is dispatched just before the collection get loaded. That means the real collection is not available in that event.

If you can't find the order items in sales_order_grid_collection_load_after, then another solution that comes to my mind is use the event sales_order_grid_collection_load_before and then join the table sales_flat_order or sales_flat_order_item into the collection. You can do join somewhat like this.

    'sales/order_item', 'order_id=entity_id',
    array('name'=>'name', 'sku' =>'sku', 'qty_ordered'=>'qty_ordered' ),
    null, 'left'

Then use sales_order_grid_collection_load_after to grab the collection again.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.