Jump to content

Mass Delete Customers / Email Subscriptions Based On List Or Csv


Recommended Posts

My shop has grown over the years, but after 11 years, there also are quite a few customers with abandoned email addresses.

 

Whenever I send out a newsletter, I get 300 emails back telling me that the email address doesn't exist anymore.

 

Exporting the emails addresses of these users into a list or CSV isn't really an issue.

 

But I'm looking for a way to remove these customer accounts or newsletter subscriptions from PrestaShop.

 

Is there any module that can do this?

Remove them using a simple list?

 

Or maybe just some small PHP script I can run (based on the remove customer script from the docs) which reads out a file with one email address per line and then removes the customer?

 

I'm fine running that directly on my servers' bash, so if anyone could help me here, it would be great :)

Link to comment
Share on other sites

You can write a simple php script.

First read your csv file into an array:

$email_array = array_map('str_getcsv', file('invalid_customers.csv'));

Then iterate through the $email_array and for each email get the customer id:

$customer_id = Customer::customerExists($email, true);

With the id load the customer and delete it:

if($customer_id) {
    $customer = new Customer($customer_id);
    $customer->delete();
}
  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...

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