允许为magento客户注册发送重复电子邮件

允许为magento客户注册发送重复电子邮件,magento,Magento,我的要求是,当客户注册电子邮件时,验证是magento的默认功能,但我们应该允许重复的电子邮件 我正在使用自定义模块以用户名(而不是电子邮件)登录到magento商店 因此,您的定制应该支持在前端注册/更新、后端(管理面板)注册/更新、从客户CSV文件导入以及从V2_API创建用户时使用重复电子邮件进行注册 如果可能的话,请详细回复我一些好的解决方案。 非常感谢您的帮助。提前感谢。Magento在Mage\u customer\u Model\u Resource\u customer类中检查了

我的要求是,当客户注册电子邮件时,验证是magento的默认功能,但我们应该允许重复的电子邮件

我正在使用自定义模块以用户名(而不是电子邮件)登录到magento商店

因此,您的定制应该支持在前端注册/更新、后端(管理面板)注册/更新、从客户CSV文件导入以及从V2_API创建用户时使用重复电子邮件进行注册

如果可能的话,请详细回复我一些好的解决方案。
非常感谢您的帮助。提前感谢。

Magento在Mage\u customer\u Model\u Resource\u customer类中检查了重复的客户电子邮件。看一看。你会发现这个函数

protected function _beforeSave(Varien_Object $customer)
{
    parent::_beforeSave($customer);

    if (!$customer->getEmail()) {
        throw Mage::exception('Mage_Customer', Mage::helper('customer')->__('Customer email is required'));
    }

    $adapter = $this->_getWriteAdapter();
    $bind    = array('email' => $customer->getEmail());

    $select = $adapter->select()
        ->from($this->getEntityTable(), array($this->getEntityIdField()))
        ->where('email = :email');
    if ($customer->getSharingConfig()->isWebsiteScope()) {
        $bind['website_id'] = (int)$customer->getWebsiteId();
        $select->where('website_id = :website_id');
    }
    if ($customer->getId()) {
        $bind['entity_id'] = (int)$customer->getId();
        $select->where('entity_id != :entity_id');
    }

    $result = $adapter->fetchOne($select, $bind);
    if ($result) {
        throw Mage::exception(
            'Mage_Customer', Mage::helper('customer')->__('This customer email already exists'),
            Mage_Customer_Model_Customer::EXCEPTION_EMAIL_EXISTS
        );
    }

    // set confirmation key logic
    if ($customer->getForceConfirmed()) {
        $customer->setConfirmation(null);
    } elseif (!$customer->getId() && $customer->isConfirmationRequired()) {
        $customer->setConfirmation($customer->getRandomConfirmationKey());
    }
    // remove customer confirmation key from database, if empty
    if (!$customer->getConfirmation()) {
        $customer->setConfirmation(null);
    }

    return $this;
}
如果您要允许重复的客户电子邮件,您可以注释掉此代码

    $adapter = $this->_getWriteAdapter();
    $bind    = array('email' => $customer->getEmail());

    $select = $adapter->select()
        ->from($this->getEntityTable(), array($this->getEntityIdField()))
        ->where('email = :email');
    if ($customer->getSharingConfig()->isWebsiteScope()) {
        $bind['website_id'] = (int)$customer->getWebsiteId();
        $select->where('website_id = :website_id');
    }
    if ($customer->getId()) {
        $bind['entity_id'] = (int)$customer->getId();
        $select->where('entity_id != :entity_id');
    }

    $result = $adapter->fetchOne($select, $bind);
    if ($result) {
        throw Mage::exception(
            'Mage_Customer', Mage::helper('customer')->__('This customer email already exists'),
            Mage_Customer_Model_Customer::EXCEPTION_EMAIL_EXISTS
        );
    }

或者你最好重写客户资源。我建议你重写一下。希望这能有所帮助。

据我所知,允许多个帐户注册到同一电子邮件地址的网站并不多。我不会经历这种混乱,除非客户真的有必要拥有更多的账户。