I try to get all the products from an order in the success.phtml This is what I try so far:

$order = Mage::getSingleton('sales/order'); 
$_items = $order->getAllItems();
echo count($_items);
foreach($_items as $_item) {

$order->getAllItems(); gives me a empty Array.

What is the right way to get the products from the order?

1 Answer 1


The problem here is that the function getLastRealOrderId will return the order increment id, in the default case 100000002 or similar. This is the number that is shown to the user as order id. But the load you are calling requires the actual entity_id of the order.

If you update the order load to use loadByIncrementId then this will really load the order you are looking for.

$order = Mage::getSingleton('sales/order'); 
$_items = $order->getAllItems();
echo count($_items);
  • 1
    Another thing to note is that $_items will be list of order items not products. If you need product details, you will have to fetch product from order item. Oct 2, 2013 at 17:12
  • thanks that works. I get all data I need, for example the sku: $_item->getProduct()->getData("sku"). Only thing I didn't find yet is the quantity of the orderitem. $_item->getQty() returns nothing.
    – nbar
    Oct 3, 2013 at 8:15
  • @myself: $_item->getQtyToInvoice()
    – nbar
    Oct 3, 2013 at 8:18
  • try one of getQtyBackordered getQtyOrdered getQtyCanceled getQtyInvoiced getQtyRefunded getQtyShipped depending on what you need to show. They can be found against Mage_Sales_Model_Order_Item Oct 3, 2013 at 8:19

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.