How to delete an order in Magento (not just cancel) (Magento1)


If you are a Magento developer you know that Magento’s administrative area doesn’t allow you to delete orders.  Magento only allows you to cancel an order.  However, that means it still remains in the database as a cancelled order. It also means it will still show up in the administrative area as a cancelled order.  This isn’t ideal as most developers create multitudes of dummy orders while they are setting up and testing Magento. This article will show you how to delete an order in Magento, not just cancel it. 


First, let’s cancel the orders that we eventually want to delete.  Go into the administrative area.  Next, navigate to Sales->Orders.  Click the checkbox of the orders you want to cancel.  Finally, click on the ‘Action’ dropdown and select ‘Cancel’ and then click the ‘Submit’ button.  This will change the status of your order(s) to ‘cancelled’ in the database.  But we want to know how to delete an order in Magento, not just cancel it. Don’t worry, there are several ways in which to change the cancelled orders to deleted orders.

Caution! Before you begin make a backup of your database just in case anything goes wrong and you delete the wrong data.

Run a query in the database

If you are using phpMyAdmin you can navigate to your database and run a sql command to delete all the cancelled orders.  Here is a sample of the query you want to use:

DELETE FROM sales_flat_order
WHERE status = ‘cancelled’

If you have just installed Magento and want to delete all orders you can also just clear out the rest of the order tables.  If not you need to write down the order entity_id’s and then delete those in the following tables:  Below are sample queries to delete all items in a table and then to delete items by entity_id.  Note: in the table sales_flat_order_item the entity_id is called the order_id.

DELETE FROM sales_flat_order_payment
WHERE entity_id >= ‘0’

DELETE FROM sales_flat_order_payment
WHERE entity_id = ‘your_entity_id_here’

Write a script to delete orders

If you are an experienced php developer you can also write a php script to delete all cancelled orders.  Basically you will want your script to loop through deleting cancelled orders.  During each loop, before  you delete the order row, get the entity_id of the order  and then delete the row with that order in the following tables: 

Again, remember that in sales_flat_order_item the entity_id is called the order_id rather than entity_id.  Once you have created and debugged your script you can run it every time you need to delete cancelled orders.

Use a Magento Extension

There are several Magento Extensions that have been created just to allow  you to delete orders.  To find the extension you want to use go to and search for ‘delete orders’.  This will give you a list of extensions to choose from.

If you find you need expert help on  how to delete an order in Magento contact Brian Wade at

case studies

See More Case Studies

Contact us

Partner with Us

We’re happy to answer any questions you may have and help you determine which of our services best fit your needs.

Your benefits:
What happens next?

We Schedule a call at your convenience 


We do a discovery and consulting meeting 


We prepare a proposal 

Schedule a Free Consultation
Simplifying IT
for a complex world.
Platform partnerships