How To Deal With The “You can’t delete this shop (customer and/or order dependency)” error in PrestaShop

The Multistore in Prestashop is a beautiful thing. It allows you to run multiple stores from one installation, with separate domain names, products, prices… Basically, you can run multiple webshops from a single installation.

However, if you haven’t planned things quite like you should have – which happens to me from time to time, because I’m a guy with multiple approaches for everything who then chooses the “least bad” option – there could be a time where you want to get rid of the Multistore option.

To do that, you need to follow the next few steps.

If Only Clicking Delete Did The Trick

Your first idea is probably to go to  “Advanced Parameters > Multistore” where you created the stores. By going to edit > Remove it seems like you can delete the stores, right?

Well, no. You’ll get the following error:

You can’t delete this shop (customer and/or order dependency).

Now, here comes the fun part. You would think that going to your list of Customers and Orders to delete all of them that are associated with the store would do the trick, righ?

Wrong again.

While you can delete the orders and customers (Make sure you’ve got some back-up of those orders for future reference while you are at it, having a solid administration is key for running a good business after all), that won’t clear all the references from the database, which is the reason you’re getting that error above. So, if you want to solve the problem it’s time for some…

MySQL Wizardry.

Okay, maybe not wizardry. You can simply solve the problem by going to PHPMyAdmin or the SQL editor of your choice, and running a query which we are posting below.

Credit for the query goes to “Woyjtablo” from the Prestashop Forums. Dude, you’re a life saver.

To run the query, you’ll need the store ID which you can find in Advanced Parameters > Multistore. Replace the X in the query with the ID, and run it.

DELETE ps_orders, ps_order_detail FROM ps_shop, ps_orders, ps_order_detail
WHERE ps_shop.`id_shop`= X
AND ps_orders.`id_shop`= ps_shop.`id_shop`
AND ps_order_detail.`id_order`= ps_orders.`id_order`

After you’ve executed this code, head to Prestashop and you can delete the store(s) you want to get rid of, and eventually disable the multistore feature in your site allrogether.

Happy debugging!¨




Categories: Prestashop, Various Articles

Tagged as: ,