ch_rles Posted December 11, 2012 Share Posted December 11, 2012 Hi guys, I've read a whole bunch of things about deleting orders (yes, my testing session is over). The two main solutions : Change the URL from in 'Admin > Orders' from "vieworder" to "deleteorder" (view here) Add a delete button width "this->delete true;" in AdminOrders.php (view here) seem to delete the row in ps_orders but not the data on the related tables. Actually I've made the test with the "deleteorder" URL method and the entry in ps_order_detail hasn't been deleted. (and as far as I've read, the "Delete button" is simply a shortcut to this same URL, so I didn't even take the pain to test it) (bad me). Still, there is the TRUNCATE method (view here) to start from crash again, but in my case, it can't be applied. Anyway. Since this methods don't delete orders properly I tried to write my own SQL request to delete in all related tables, and this is what I came with : DELETE o.*, od.*, odi.*, oh.*, orn.*, ord.*, os.*, osd.*, ot.*, ome.* FROM ps_orders o LEFT JOIN ps_order_detail od ON od.id_order = o.id_order LEFT JOIN ps_order_discount odi ON odi.id_order = o.id_order LEFT JOIN ps_order_history oh ON oh.id_order = o.id_order LEFT JOIN ps_order_return orn ON orn.id_order = o.id_order LEFT JOIN ps_order_return_detail ord ON ord. id_order_return = orn.id_order_return LEFT JOIN ps_order_slip os ON os.id_order = o.id_order LEFT JOIN ps_order_slip_detail osd ON osd.id_order_slip = os.id_order_slip LEFT JOIN ps_order_tax ot ON ot.id_order = o.id_order LEFT JOIN ps_message ome ON ome.id_order = o.id_order WHERE o.id_order = XXX As far as I've tested, it seems to work properly (I run Prestashop 1.4). So here are my questions : Am I wrong somewhere ? - Did I forget any related entry in my SQL request ? - Or does another method (like a cool prestashop function) exist to do it in a less risky way ? Thanks for your answers ! Link to comment Share on other sites More sharing options...
NemoPS Posted December 11, 2012 Share Posted December 11, 2012 Hi, You can also try using my free module here, it takes care of all the additional tables: http://store.nemops.com/free-modules/19-order-delete.html Link to comment Share on other sites More sharing options...
ch_rles Posted December 11, 2012 Author Share Posted December 11, 2012 Thanks for your answer, your module seems to be the best I've seen so far. But you don't deal with this table, do you ? ps_message And by the way, (sorry I didn't install it for now) does your module accept batches or do I need to delete orders ID by ID ? Link to comment Share on other sites More sharing options...
NemoPS Posted December 11, 2012 Share Posted December 11, 2012 Hi, I can't remember now, but it should take care of every sensible field. For the batch, you can delete orders from a certain id up to the current one. In fact, I definitely have to add the "range" possibility. I'll sure add this in the next release Link to comment Share on other sites More sharing options...
Recommended Posts