Delete orders of particular customer in magento

Posted: July 23, 2010 in Magento, Version 1.3.*, Version 1.4.*
Tags: , ,

Hello Everyone,

You can delete order of particular customer using below code .. You need to run below code in adminpanel.

<?php $order = Mage::getModel(‘sales/order’)->getCollection()
->addAttributeToFilter(‘customer_id’,’14’);//”14″ is a id of customer
print_r($order->count()); // It display no. of order place by customer whose id is ’14’
foreach ($order as $ord) {
echo $ord->getIncrementId() . ‘<br>’; //It display increment id of order
$ord->delete(); //This statement delete order
} ?>

I hope the above code is help you to delete sales order in magento

Bijal Bhavsar 🙂


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s