public function loadByEmail(Mage_Customer_Model_Customer $customer, $email, $testOnly = false) { $select = $this->_getReadAdapter()->select()->from($this->getEntityTable(), array($this->getEntityIdField()))->where('email=?', $email); if ($customer->getSharingConfig()->isWebsiteScope()) { $select->where('website_id=?', (int) $customer->getWebsiteId()); } if ($id = $this->_getReadAdapter()->fetchOne($select)) { $this->load($customer, $id); } return $this; }
/** * Load customer by username * * @param Mage_Customer_Model_Customer $customer * @param string $username * @return Mage_Customer_Model_Entity_Customer * @throws Mage_Core_Exception */ public function loadByUsername(Mage_Customer_Model_Customer $customer, $username) { if (!Mage::getStoreConfigFlag('username/general/case_sensitive')) { $filter = new Zend_Filter_StringToLower(array('encoding' => 'UTF-8')); $username = $filter->filter($username); } $select = $this->_getReadAdapter()->select()->from($this->getEntityTable(), array($this->getEntityIdField()))->joinNatural(array('cev' => $this->getTable('customer_entity_varchar')))->joinNatural(array('ea' => $this->getTable('eav/attribute')))->where('ea.attribute_code=\'username\' AND cev.value=?', $username); if ($customer->getSharingConfig()->isWebsiteScope()) { if (!$customer->hasData('website_id')) { Mage::throwException(Mage::helper('customer')->__('Customer website ID must be specified when using the website scope.')); } $select->where('website_id=?', (int) $customer->getWebsiteId()); } if ($id = $this->_getReadAdapter()->fetchOne($select, 'entity_id')) { $this->load($customer, $id); } else { $customer->setData(array()); } return $this; }
/** * Load customer by email * * @throws Mage_Core_Exception * * @param Mage_Customer_Model_Customer $customer * @param string $email * @param bool $testOnly * @return Mage_Customer_Model_Resource_Customer */ public function loadByEmail(Mage_Customer_Model_Customer $customer, $email, $testOnly = false) { $adapter = $this->_getReadAdapter(); $bind = array('customer_email' => $email); $select = $adapter->select()->from($this->getEntityTable(), array($this->getEntityIdField()))->where('email = :customer_email'); if ($customer->getSharingConfig()->isWebsiteScope()) { if (!$customer->hasData('website_id')) { Mage::throwException(Mage::helper('Mage_Customer_Helper_Data')->__('Customer website ID must be specified when using the website scope')); } $bind['website_id'] = (int) $customer->getWebsiteId(); $select->where('website_id = :website_id'); } $customerId = $adapter->fetchOne($select, $bind); if ($customerId) { $this->load($customer, $customerId); } else { $customer->setData(array()); } return $this; }
/** * Load customer by email * * @param Mage_Customer_Model_Customer $customer * @param string $email * @param bool $testOnly * @return Mage_Customer_Model_Entity_Customer * @throws Mage_Core_Exception */ public function loadByEmail(Mage_Customer_Model_Customer $customer, $email, $testOnly = false) { $select = $this->_getReadAdapter()->select()->from($this->getEntityTable(), array($this->getEntityIdField()))->where('email=:customer_email'); if ($customer->getSharingConfig()->isWebsiteScope()) { if (!$customer->hasData('website_id')) { Mage::throwException(Mage::helper('customer')->__('Customer website id must be specified, when using website scope.')); } $select->where('website_id=?', (int) $customer->getWebsiteId()); } if ($id = $this->_getReadAdapter()->fetchOne($select, array('customer_email' => $email))) { $this->load($customer, $id); } else { $customer->setData(array()); } return $this; }