Question

I have some spam customer so how can i remove spam customer account in this site and how to disallow this account through the extension for Magento 1.9
please give me a suggestion for that if any extension link or tool then give me for Magento 1.9 please help me. Thank you.

Was it helpful?

Solution

HI Mohit I have no any Extention but I have one script for this your requirement is fulfilled

<?php 
require 'app/Mage.php';
Mage::app('admin')->setUseSessionInUrl(false);


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

$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");
}

I hope this can help you!

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top