Deleting Orders in Magento – Extension Roundup

With a default Magento installation it is not possible to delete orders once they have been placed. Fortunately there are quite a few extensions out there which try to fix this shortcoming. I have put them to the test with the following methodology:

  1. Freshly install Magento with sample data (I used 1.4.1.1)
  2. Install DeleteExtension
  3. Take database backup
  4. Place 3 test orders
  5. Invoice and ship order 1
  6. Invoice, ship and refund order 2
  7. Create multiple invoices and partial ship order 3
  8. Delete all 3 test order
  9. Take another database backup
  10. Compare the two DB backups

Expected outcome: Identical databases (with the exception of logged url visits/products viewed)
Bonus points for an option to reset the numbering of subsequent orders/invoices/shipments and creditmemos to fill the gaps in the numbering or in the case of deleting all orders to start again at 1 (see footnote – order numbers)

Asperience_DeleteAllOrders-0.1.2

  • Test Order 3 could not be deleted since some items were still unshipped. Error message displayed “To be deleted, the sales orders must be cancelled, complete or closed.” To complete the test the remaining items were also shipped.
  • Differences in stock (cataloginventory_stock_item/cataloginventory_stock_status) – the decrease in stock was not reversed
  • Original quote data remains (sales_flat_quote/sales_flat_quote_address/sales_flat_quote_item/sales_flat_quote_item_option/sales_flat_quote_payment/sales_flat_quote_shipping_rate)
  • Differences in collected tax (sales_order_tax)
  • AUTO_INCREMENTs were not reset (see footnote)
  • The next order placed would receive the order number 100000004

EM_DeleteOrder-1.0.5

  • All orders were deleted and not visible in the order grid page any longer.
  • Differences in stock (cataloginventory_stock_item/cataloginventory_stock_status) – the decrease in stock was not reversed
  • Differences in collected tax (sales_order_tax)
  • AUTO_INCREMENTs were not reset (see footnote)
  • The next order placed would receive the order number 100000004

Wyomind_OrdersEraser-2.0.2

  • All orders were deleted and not visible in the order grid page any longer.
  • Differences in stock (cataloginventory_stock_item/cataloginventory_stock_status) – the decrease in stock was not reversed
  • Original quote data remains (sales_flat_quote/sales_flat_quote_address/sales_flat_quote_item/sales_flat_quote_item_option/sales_flat_quote_payment/sales_flat_quote_shipping_rate)
  • Differences in collected tax (sales_order_tax)
  • AUTO_INCREMENTs were not reset (see footnote)
  • The next order placed would receive the order number 100000004

Alternatives

DB Backup/Restore

Create a backup before placing test orders and then restore it afterwards
- no selective delete
- requires discipline to not change settings, products, etc which you want to use long term between the backup and restore
+ can reset order numbering and increments
+ resets inventory information

Manipulate DB directly

see for example posts ,  and here
- no selective delete
- required mysql is potentially different for every Magento version
- doesn’t deal with inventory
- most posted scripts receive less feedback then extensions
+ can reset order numbering and increments

Only place test orders on a test site

+ nothing to delete
- not addressing the issue of deleting orders

Notes

AUTO_INCREMENT

Magento uses the automatically incremented value assigned by the database as id for pretty much everything. Unfortunately when selectively deleting any records you can’t easily fill those gaps without making major changes to Magento itself. For example if you have records 1,2,3,4 and delete 2,3 your database will always display this hole and the next record will have id 5. In most scenarios this won’t matter but worth keeping in mind if you require consecutive ids (different to the increment ids). The only way to address this is to delete all orders and not only selective orders and then set Mysql’s auto_increment value back to its starting value.

Resetting Order Numbers

The most common scenario for the use of DeleteOrder extensions is to delete test orders placed before a shop goes live. Ideally you would then start fresh with order numbers starting at 1. None of the extensions in this round-up offered an option to do this.

As a word of caution some 3rd party payment gateways force you to use unique references. When you reset the numbering you would submit the same number twice. Paypal Standard is a good example if you use the setting
Profile >Payment Receiving Preferences > You may prevent accidental payments by blocking duplicate invoice IDs > Yes, block multiple payments per invoice ID
If you previously tested against a live paypal account your first customers after the reset would not be able to checkout and pay. Not a good launch!

Comments

Leave a Reply

Your email address will not be published.

13 + twelve =

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Security Code: