1

Guy's I have a Magento 1.9 site and some days ago I check my admin side so found lot's of spam customer so I can add google Recaptcha at that time.

But it already has many customers are in site so how can I remove in my site if any suggestions like any module or custom script so please help me.

1

You have create root script this way and filter one by one like @qq.com and remove it

<?php 


 /**
 * Delete Customers
 *
 */
require 'app/Mage.php';
Mage::app('admin')->setUseSessionInUrl(false);


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

# $customerCollection->printLogQuery(true); 

$customerIds = array();
foreach ($customerCollection as $customer) {
    $customerIds[] = $customer->getEntityId();
}

$customerCollectionNew = Mage::getModel('customer/customer')->getCollection()
                ->addAttributeToFilter('entity_id', array('in' => $customerIds))

if ($customerCollectionNew->count()) {
    foreach ($customerCollectionNew as $customer) {
        try {
            $id = $customer->getId();
            $customer->delete();
            echo 'Customer '.$id.' is deleted.<br/>';

            Mage::log('Customer '.$id.' is deleted.<br/>', null, "customer-delete.log");
        } catch (Exception $e) {
            echo "Customer ".$id." is deleted: " . $e->getMessage() . '<br/>';
            Mage::log("Customer ".$id." could not be removed: " . $e->getMessage(), null, "customer-delete.log");
        }
    }
    echo "<br>";
    echo "Completed.";
    Mage::log("Completed.", null, "customer-delete.log");
}

Note: I have no test my code you can check it taken one email address

  • HI @rakesh but I have no only qq.com domain multiple domains found in the admin side and like 3000 or 4000 customers are in spam so you please give full script or suggest another script if it is possible. – Rohit Gohel Oct 10 at 6:44
  • @RohitGohel i have updated my answer but you want to manually filter set like qq.com – Rakesh Donga Oct 10 at 6:49
  • HI @rakesh script is working fine but we have many domains so work is hard to find the one bye one domains but thanks for the helping. – Rohit Gohel Oct 10 at 7:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.