Jump to content

How to completely delete a customer from my DB?


Recommended Posts

I deleted a number of test orders from my back end however I noticed that they were still appearing in my newsletter CVS export and some other places.


So I think the only way to completely delete them is via the DB.

I found customer data in four main tables:

1) Customer
2) Address
3) Order
4) Order detail

(I take it cart data doesn't really matter)


Now...I don't want to accidentally delete anything important so I have two questions:

1) Can I simply delete customers directly from the DB? Or will this have far reaching implications (e.g. when it tries to increment the next customer ID it will throw an error)?

2) Can I get away with deleting records only from the Customer table, and forget the other three? I'm just not very confident about messing with those other tables without making a mistake.

Link to comment
Share on other sites

  • 4 weeks later...

I'm having the same issue I believe. Yes in the back office it appears that you can delete a customer. And in that particular table your customer is deleted. However if you go to put a customer with the same email address it will not let you. So the customer still resides in the database under the database ps_customer. From what I can tell there doesn't seem to be any affect in deleting the row in that database after the fact.

It seems that the code to delete the customer isn't touching all of the databases it needs to. The if statement that is controlling the delete button on that particular page is nested and appears to be generic, i.e. for deleting a number of entities from the backend. Does there need to be a further if statement to specify if it's a customer entity to also delete from the ps_customer table? The exact code that is needed I'm not sure, just think I'm on the right track...

Link to comment
Share on other sites

Actually I believe I found a way to actually delete the customer from the backend.

change
$this->table = 'customer';
$this->className = 'Customer';
$this->lang = false;
$this->edit = true;
$this->view = true;
$this->delete = true;
$this->deleted = true;

to

$this->table = 'customer';
$this->className = 'Customer';
$this->lang = false;
$this->edit = true;
$this->view = true;
$this->delete = true;
//$this->deleted = true;

Or in other words remove the $this->deleted = true; statement. Just want to verify will this cause other issues along the way?

Link to comment
Share on other sites

ok I can confirm that what smrdawg has given works but what about the other occurance in orders, order details and address? will there be any implication to the workingness of prestashop if we delete the rows from the database and not from BO? Some help here from the moderators please.

Regards
Archproject

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...