Jump to content

Clean DB-tables ps_cart_product, ps_cart and ps_guest


redrum

Recommended Posts

I'm about to finish a small script that could do some cleanup in the database.
I'm hoping for some thoughts about the scenario below.

Have I missed something?
Will it mess up anything so something wont work properly?


Here we go;

1. If a product is out of stock you might want to delete it from the tables `ps_cart_product`.
2. This will result in some rows in `ps_cart` doesn't  have any corresponding product in `ps_cart_product`, so then we remove these rows in the table `ps_cart`.
3. Lastly we clean up the table `ps_guest`.

It is done in the following order with the following conditions:

Conditions for cleaning table `ps_cart_product`:
- Product quantity is set to 0.
- Row is not related to an order.

Conditions for cleaning table `ps_cart`:
- Row does not exist in the table `ps_cart_product`.
- Row does not exist in the table `orders`.

Conditions for cleaning table `ps_guest`:
- Row does not exist in the table `ps_cart`.
- Row does not exist in the table `pf_connections`.
- `id_customer` is 0.

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...