Last active
December 5, 2017 00:27
-
-
Save tiagosampaio/66f3506acd3fc8a87d915e54d64fc1a8 to your computer and use it in GitHub Desktop.
Code Example Customer Model in Magento 1.9.3.1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Authenticate customer | |
* | |
* @param string $login | |
* @param string $password | |
* @throws Mage_Core_Exception | |
* @return true | |
* | |
*/ | |
public function authenticate($login, $password) | |
{ | |
$this->loadByEmail($login); | |
if ($this->getConfirmation() && $this->isConfirmationRequired()) { | |
throw Mage::exception('Mage_Core', Mage::helper('customer')->__('This account is not confirmed.'), | |
self::EXCEPTION_EMAIL_NOT_CONFIRMED | |
); | |
} | |
if (!$this->validatePassword($password)) { | |
throw Mage::exception('Mage_Core', Mage::helper('customer')->__('Invalid login or password.'), | |
self::EXCEPTION_INVALID_EMAIL_OR_PASSWORD | |
); | |
} | |
Mage::dispatchEvent('customer_customer_authenticated', array( | |
'model' => $this, | |
'password' => $password, | |
)); | |
return true; | |
} | |
/** | |
* Load customer by email | |
* | |
* @param string $customerEmail | |
* @return Mage_Customer_Model_Customer | |
*/ | |
public function loadByEmail($customerEmail) | |
{ | |
$this->_getResource()->loadByEmail($this, $customerEmail); | |
return $this; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment