0

I am new to magento.I want to check the user provide email is already exist or not on custom registration page. I tried this with java script (apply in same file)but it shows html content in response text.

5
$customer = Mage::getModel('customer/customer');
$customer->setWebsiteId(Mage::app()->getWebsite()->getId());
$customer->loadByEmail($customer_email);

if($customer->getId())
{
  "Customer Exist";
}

You can check this by server side and send status in response.

  • hi its working fine but reloading page .Is it possible to check this without reloading page? – Urvashi Sep 7 '15 at 7:03
  • For that you can do it two ways. 1. Do AJAX call and check it at server side and get the status in response on form submission. 2. Create java-script array of all email ids in system and check email exist in array or not after submit the form. – Akhilesh Patel Sep 7 '15 at 7:10
  • how?can you please give some working example? – Urvashi Sep 7 '15 at 7:19
1
$email ="xyz@gmail.com";
$customer = Mage::getModel('customer/customer')->setWebsiteId(Mage::app()->getWebsite()->getId())->loadByEmail($email);
if($customer->getId()){
    echo "customer exists";
}else{
 echo "customer doesn't exists";
}
0

You basically have three options: Y ou could query to API (SOAP or REST) to check for existing customer with given e-mail,

you could write a custom extension that provides this functionality through JavaScript and an additional URL to query, search for existing extensions that incorporate this function.

But: The check for existing e-mail is a built-in function, although not client-side only in most of the templates available.

0
$customerObj = Mage::getModel("customer/customer");
    foreach (Mage::app()->getWebsites() as $website) {
        $customerObj->setWebsiteId($website->getId());
        $customerObj->loadByEmail($customer['email']);
        if ($customerObj->getId()) {
          $message = "duplicate found" ;
          return $message;
       }

    }
  • Welcome on Magento SE. Code-only answers are discouraged here. Could you please provide a small explanation for your code? – Julien Lachal Jan 26 '17 at 16:18

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.