Question

How I can filter Magento order by any customer email id? I'm doing something like but I'm not getting the result.

$customer_email ='abc@gmail.com';
$orders = Mage::getModel('sales/order')->getCollection()
    ->addFieldToFilter('customer_email', $customer_email);
Was it helpful?

Solution

Use addAttributeToFilter instead of addFieldToFilter as in some case Sales model follow eav patten filter and select.

$customer_email ='abc@gmail.com';
$orders = Mage::getModel('sales/order')->getCollection()
    ->addAttributeToFilter('customer_email', $customer_email);

OTHER TIPS

Use the following code for filter the order collection with customer email it's working fine with my magento hope this will help you

$order_collection = Mage::getModel('sales/order')->getCollection();
$order_collection->addFieldToFilter('customer_email','abc@domain.com');
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top