We use cookies to improve our services and provide a better experience. By continuing to use this site, you agree with our Cookies Policy.

Tutorials
More than 400 step-by-step articles to guide you through online project development.
HomeTutorialsCMS TutorialsMagentoMagento Administration

How to Completely Delete Orders in Magento

Windows Cloud Server
Germany Cloud Servers
OpenVZ VPS
Linux KVM Hosting
cPanel KVM
KVM VPS
Linux Cloud Server
Brazil VPS
Ubuntu VPS
USA VPS

In case you would like to delete unwanted orders from Magento admin backend, you have several options. Here we will a explain few of them.

Follow These Steps to Completely Delete Orders in Magento

In the oldest versions of Magento, it was not possible to delete the order completely. It was only possible to set order status to “cancelled”. Therefore, as a workaround it was possible to delete the order by executing MySQL query below:

1
2
 select @order_id:=entity_id from sales_order_entity where increment_id='100000001';
delete from sales_order_entity where entity_id=@order_id or parent_id=@order_id;

As shown in the queries, first you are going to select order ID from the sales table and delete it by using the second query. This method can be used by executing MySQL query in phpMyAdmin interface. Simply open Magento database and click on “SQL” tab. Then put required SQL query and execute it.

For the newer versions of Magento, there are more comfortable ways to delete the orders. One of them by using PHP script which will find defined order and delete it from the orders list. The script can be found below.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
$incrementId = 100000001;
 
$order = Mage::getModel('sales/order')->loadByIncrementId($incrementId);
$invoices = $order->getInvoiceCollection();
foreach ($invoices as $invoice){
$invoice->delete();
}
$creditnotes = $order->getCreditmemosCollection();
foreach ($creditnotes as $creditnote){
$creditnote->delete();
}
$shipments = $order->getShipmentsCollection();
foreach ($shipments as $shipment){
$shipment->delete();
}

There you will need to define increment ID which will be used to search for the orders. Usually, this ID contains only numbers like “100000037”. Then by using Magento functions it will go through all the orders and get required order which increment ID will match the defined one. This script can be implemented and used in Magento admin backend as a quick tool for deleting orders completely.

In case you are looking for a completely built in feature for deleting the orders, there is even an extension which will let you to delete the orders. Extension can be installed by visiting Magento Connect website and clicking “Install Now”. Please note, to get this extension installed, first you will need to be logged in to Magento Connect website. This means registration is required. After installing this extension, simply open orders list in Magento admin backend and select the order which needs to be deleted. Then select “Delete order” from the “Actions” list and click “Submit” button. Order will be deleted successfully.

Brazil VPS
USA VPS
Germany Cloud Servers
Linux KVM Hosting
OpenVZ VPS
cPanel KVM
Windows Cloud Server
KVM VPS
Linux Cloud Server
Ubuntu VPS
Rate this Tutorial:
No Comments Leave a Comment
Leave a Comment