cancel
Showing results for 
Search instead for 
Did you mean: 

How do i delete 6000 customers

SOLVED

How do i delete 6000 customers

A bot has recently created more than 6000 accounts, and they all have an e-mail adres @qq.com . 

what is the best way to remove these accounts in phpMyadmin ?

1 ACCEPTED SOLUTION

Accepted Solutions

Re: How do i delete 6000 customers

Above solution not work practically because it would delete from "customer_entity" table only., what if have records into child tables. Use below code to delete customers.

 

$customers = Mage::getModel("customer/customer")
			->getCollection()
			->addAttributeToFilter('email', array('like' => '%@qq.com'));

foreach ($customers as $customer) {
    $customer->delete();
}

exit("customers deleted");

Good luck Smiley Happy

-
Magento Programmer | Was my answer helpful? You can accept it as a solution.

View solution in original post

4 REPLIES 4

Re: How do i delete 6000 customers

Hi,

Please have a backup of your DB before executing the following commands.
Execute this sql query directly on your database 
If you use table name prefixes please change the table names accordingly

 

DELETE FROM `customer_entity` WHERE email ='a@b.com';

Re: How do i delete 6000 customers

Above solution not work practically because it would delete from "customer_entity" table only., what if have records into child tables. Use below code to delete customers.

 

$customers = Mage::getModel("customer/customer")
			->getCollection()
			->addAttributeToFilter('email', array('like' => '%@qq.com'));

foreach ($customers as $customer) {
    $customer->delete();
}

exit("customers deleted");

Good luck Smiley Happy

-
Magento Programmer | Was my answer helpful? You can accept it as a solution.

Re: How do i delete 6000 customers

The cascading deletes on the DB should take care of entries in the child tables (customer address etc) therefore the sql given in the original answer is the better one to use and a lot less resource hungry.

Richard Cleverley
Magepim Ecommerce Services

Re: How do i delete 6000 customers

Witch answer do you prefer ?

The answer from GMehta or Magikvishal