订单页面上的Magento:"此客户电子邮件已存在"

Isa*_*c Y 4 migration magento magento-1.6

我使用一些迁移工具将订单导入Magento.当退货客户试图下订单时,Magento会阻止他们这样做,并说"此客户电子邮件已经存在".尽管事实上他们已经登录了Magento.

我是否错误地导入/迁移到Magento数据库?或者其他可能导致这种情况?

任何建议都非常感谢.

Ole*_*nko 9

您获得的例外是由客户资源模型的_beforeSave 函数生成的,该函数检查具有给定电子邮件地址的客户是否存在.支票代码:

    $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
        );
    }
Run Code Online (Sandbox Code Playgroud)

您的客户已登录,这意味着条件$customer->getId()为真.但是,既然你得到了一个例外,我建议,有一些重复的客户帐户使用相同的电子邮件.

您的导入工具是否在客户数据中创建了重复项?这是我能想到的唯一原因.使用此查询检查数据库:

 select email, count(*) from customer_entity group by email having count(*) > 1
Run Code Online (Sandbox Code Playgroud)