roberto06 Posted January 24, 2014 Share Posted January 24, 2014 Hi, A client of mine is facing a problem : he can't seem to delete products from the BO if they have already been ordered. I figured the deletion in the DB can't be done because of a foreign key issue, so I deleted the foreign key on id_product in the table ps_order_detail, but it still doesn't work. Obviously, i could delete all the concerned products directly in the DB, but I need a way to make it work from the BO, in order for my client to be able to do it by himself. I have full access on the source code and the DB, and the PS version of this website is 1.4.7.0 Any help is appreciated, thanks. Link to comment Share on other sites More sharing options...
El Patron Posted January 24, 2014 Share Posted January 24, 2014 native ps does not support deletion of products (as you know) when they are associated to errors. Deleting them can lead (probably will) to unpredictable results. Could you not just 'disable' the product? Link to comment Share on other sites More sharing options...
roberto06 Posted January 24, 2014 Author Share Posted January 24, 2014 Nope, that would be too easy My client absolutely wants these products to be deleted, to clean the database. Anyway, I did the test on a "clean" Prestashop (1.4.8.2), and I was able to delete ordered products such as the iPod Touch, though this product was in an order I manually validated. Link to comment Share on other sites More sharing options...
El Patron Posted January 24, 2014 Share Posted January 24, 2014 be as that may (you deleted one) this does not guarantee you will have issue later on, ghost products etc. maybe this will work adminfolder/AdminOrders.php Add the line as seen below http://screencast.com/t/W5w6zCewh rememember, tell the client the truth...that this can cause issues..especially if they have modules that look at orders Link to comment Share on other sites More sharing options...
roberto06 Posted January 24, 2014 Author Share Posted January 24, 2014 It still doesn't work While I completely agree with you that a simple deactivation would be enough, I'm not sure my client will understand the risks of deleting a product. Anyway, I'll try to convince him, but if you have another idea, I'll take it, I feel like I have tried everything. Thx anyway Link to comment Share on other sites More sharing options...
roberto06 Posted January 24, 2014 Author Share Posted January 24, 2014 What I really do not understand, is why the deletion works on other websites (I have another client who sells clothes and has a new collection every 6 months, and never had any issue whatsoever with the deletion of a product), but not on this one... Link to comment Share on other sites More sharing options...
El Patron Posted January 24, 2014 Share Posted January 24, 2014 just tell him that moderators on forum...DO NOT RECOMMEND this idea. otherwise, say yes I can do it for 1,000,000 euros....that usually stops them from shooting themselves in the foot 1 Link to comment Share on other sites More sharing options...
El Patron Posted January 24, 2014 Share Posted January 24, 2014 are these test orders? if so try this, for each order, cancel the order... Link to comment Share on other sites More sharing options...
roberto06 Posted January 24, 2014 Author Share Posted January 24, 2014 (edited) These aren't test orders (most of them are already cancelled anyway), and I'll use the 1000000€ argument, I like it Anyway, I found a (dirty) workaround, by commenting these lines in classes/Product.php : public function delete() { // check if the product is not used in a non validated order // if (!$this->isDeletable()) <- THIS LINE // return false; <- AND THIS ONE if (!GroupReduction::deleteProductReduction($this->id)) return false; The verification in the table ps_order_detail is not done, and the deletion works... I'll inform the client that this may cause problems on the website and that I'd rather not do it, for the sake of his website. Thanks for everything. Edited January 24, 2014 by roberto06 (see edit history) 1 Link to comment Share on other sites More sharing options...
Recommended Posts