Magento – How to get all orders id for curent customer

adminhtmlcustomergridmagento-1.9orders

I need to get all orders id for current customer in my custom customer tab!

I'm using: $orders = Mage::getModel('sales/order')->getCollection();

This is my Tab where I want to add Order No and Sum:

enter image description here

Best Answer

magento is stored customer_email in order table(sales_flat_order)

Now you can order list of order by using email id and but need fetch current customer email id then you can customer order list by below code:

$orderCollection = Mage::getModel('sales/order')->getCollection()
->addFieldToFilter('customer_email',$customerEmail)->addFieldToSelect('*');

foreach($orderCollection as $order){
    echo "<pre>";
    print_r($order->getData());
    echo "</pre>";
}
Related Topic