Jump to content

Cannot delete product if already ordered


Recommended Posts

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

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

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

 

01.24.2014-08.24.png
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

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

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

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 by roberto06 (see edit history)
  • Like 1
Link to comment
Share on other sites

×
×
  • Create New...