In Magento 1.9, the "dashboard" and "order history" pages contain table of orders with summary info (date, order #, total) but not some helpful details (product image, product name, line price, quantity).

UX would be improved by highlighting the products in each order so the list of orders is more visual.

— — — — — — — — — —

Q: how can we load the product data for each order in the loop of orders without harming performance?

— — — — — — — — — —

Relevant files:


Relevant code:

$orders = $this->getOrders();

foreach ($orders as $order) {
    echo $order->getRealOrderId();
    echo $order->getStatusLabel();
    // [todo] get products in order (name, image, url, price paid)

Note: I'm a frontend developer, so please bear with me. A little more detail than just override X class or use Y model is helpful.

1 Answer 1


Heres a straightforward way that will do the trick. It's a bit messy since the info you need requires getting not just the order items but the corresponding products as well. I suppose that's Magento though.

$orders = $this->getOrders();

foreach ($orders as $order) {
    /* @var $order Mage_Sales_Model_Order */
    $items = $order->getAllVisibleItems();
    $product_info = [];
    foreach ($items as $item) {
        /* @var $item Mage_Sales_Model_Order_Item */
        /* @var $product Mage_Catalog_Model_Product */
        $product = $item->getProduct();
        $product_info[] = [
            'name'  => $item->getName(),
            'price' => Mage::helper('core')->currency($item->getPrice(), true, false),
            'url'   => $product->getProductUrl(),
            'image' => $this->helper('catalog/image')->init($product, 'small_image')->resize(75, 75),


This is probably not the most performance-friendly way though. With a large list of orders, I expect this could slow down page load. Hard to say until you test it. If better performance is needed, I'd look at extending these two block classes:


Override the constructor methods since that's where the order collections are originally loaded. A collection of Order Items and Products can be loaded there and attached to the Orders collection. This would be more efficient than loading order items and products for each order in a loop.

  • This is perfect! Making a couple edits so it's a more functional response. $order->getAllItems() changed to $order->getAllVisibleItems(). Add price formatter. Added image URL via helper. Commented Sep 12, 2017 at 22:12
  • Performance seems fine. A user would never see more than 10 orders per page. Might be slower if the orders have a huge amount of products, but not crazy slow to avoid it. Thanks! Commented Sep 12, 2017 at 22:15
  • Glad it fits the bill! No sense over optimizing if it's not needed. Those helper methods are definitely the proper way to go too. Commented Sep 13, 2017 at 0:54

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.