0

I have tried this to load

$orders = Mage::getModel('sales/order')->load(1100000255);

but this is solution for to load order information of that particular orderId.

But i need to know order summary of particular Customer with his or her Customer id.

1

to load this order you need to loadByIncrementId

$orders = Mage::getModel('sales/order')->loadByIncrementId(1100000255);

if you want customer order by customer id then

$customer_id = 5;
    $_orders = Mage::getModel('sales/order')->getCollection()->addFieldToFilter('customer_id',$customer_id); 
3
  • these will return all order details of customer_id = 5 good but next i want to get only first order date and last order date of specific customer_id order. – Sarfaraj Sipai May 24 '18 at 6:07
  • 1
    $_orders = Mage::getModel('sales/order')->getCollection()->addFieldToFilter('customer_id',$customer_id); $_orders->setOrder('entity_id','DESC'); $_orders->getFirstItem(); or chnage order to created_at – Qaisar Satti May 24 '18 at 7:17
  • i have did that i want only order date like same but different filter i have used and got the actual result which i want. Thanks for reply – Sarfaraj Sipai May 24 '18 at 7:47
0

1100000255 is order increment id not order id for system.

For getting order details by increment id ,You need to use loadByIncrementId()

$order = Mage::getModel('sales/order')->loadbyIncrementId(1100000255);

Note: loadByIncrementId() give single order not multiple Order

For Getting Orders of a particular Customer id then You should Call Sales order Collection Mage::getModel('sales/order')->getCollection() Then filter that Collection id by field customer_id

$Collection=Mage::getModel('sales/order')->getCollection();
$Collection->addFieldToFilter('customer_id',$customerId)

That collection can be filter by any fields of sales_flat_order table,So as per as ,require you can get orders collection customer name, Customer email etc.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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