Yireo - Extensions, tutorials and blog for Magento and Joomla!

Blog Tags

MageBridge Standard

Magento Delete-Any-Order module released

Friday, 28 August 2009

yireo-delete-any-orderYireo has released today a new Magento module called Delete-Any-Order. Magento by itself does not offer the feature to delete orders, and other third party modules only allow to delete orders which are pending. The Yireo Delete-Any-Order module deletes orders with any status, and also deletes all related information with it.

The problem of deleting orders

Magento does not offer a way to delete orders. This may sound very strange but the main reason here is that as soon as an order is placed, the book-keeping starts. And because messing around with financial records is unwanted, removing orders is disabled - especially when an order is already accompanied by an invoice.

In most countries invoices need to be sequentially numbered and all orders should be accounted for. If an order or an invoice would be deleted, the book-keeping has holes in it. But there are a few exceptions here.

For instance, when you're building a site you want to have a smooth way of deleting orders without cleaning up the whole database. Or if your financial records are kept in a different system than Magento, it doesn't matter if the book-keeping in Magento is a bit flawed. The Yireo Delete-Any-Order solves this by allowing you to delete orders anyway.

Not just a bunch of database queries

Deleting orders is more than just performing a few database queries. First of all, an order is a so-called EAV entity, which means that its database-values are not stored in a single database table, but stored in various tables instead. Also, one order actually involves multiple EAV-entities that all point to the same thing: Orders, order comments, order items.

But everything really becomes more complicated as soon as the order changes status from Pending to Completed. On top of the existing order-entries, invoices are created (together with comments), a shipment is initialized (together with comments) and payment information is kept track of (together with comments).

Other pieces of information that are added include order tracking (like with UPS) and credit memos. The Delete-Any-Order module attempts to remove those pieces of the order that are stored inside Magento. Outside of Magento, there might be other things set in motion making deleting the order even harder (actual payments, actual shipment) but this is outside the scope of the module.

Warning for third party modules

Third party modules can extend Magento in various ways. For instance, they could introduce their own Product Type and sell products based in that new type just like regular products. But selling those products also means that extra information is added to the order.

The product-type Downloadable is a good example of this. It adds information related to specific orders to its own two database tables. When deleting an order, this information is to be deleted as well. The Delete-Any-Order module supports the deletion of Downloadable Products (as this is part of the Magento core), but there might be other modules out there that need support as well.

Instead of incorporating the order deletion into this Delete-Any-Order module, Magento offers a much smarter way to do this. Every module that extends the order-information probably does so through events. The only thing those modules need to do is also listen to the event "sales_order_delete_after" - this is called by the Yireo Delete-Any-Order module but also other modules that delete orders.

Availability

The Yireo Delete-Any-Order module is available in our Yireo Shop for a price of 20 Euro.

Tags: magebridge

About Yireo

Yireo tries to help webdevelopers build successful Joomla! and Magento sites.

More about Yireo