4

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

1
  • you need put new question.. question was totally changed
    – Amit Bera
    Commented Oct 29, 2014 at 10:50

2 Answers 2

3

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>";
}
2

Please user the below code.

$orders = Mage::getResourceModel('sales/order_collection')
            ->addFieldToSelect('*')
            ->addFieldToFilter('customer_id',Mage::getSingleton('customer/session')->getCustomer()->getId())
            ->setOrder('created_at', 'desc'); 

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.