【发布时间】:2013-02-20 14:13:15
【问题描述】:
我使用一些迁移工具将订单导入 Magento。当回头客尝试下订单时,Magento 阻止他们这样做并说“此客户电子邮件已存在”。尽管他们已经登录到 Magento。
我是否错误地导入/迁移到 Magento 数据库?或者可能是其他什么原因造成的?
非常感谢任何建议。
【问题讨论】:
标签: magento migration magento-1.6
我使用一些迁移工具将订单导入 Magento。当回头客尝试下订单时,Magento 阻止他们这样做并说“此客户电子邮件已存在”。尽管他们已经登录到 Magento。
我是否错误地导入/迁移到 Magento 数据库?或者可能是其他什么原因造成的?
非常感谢任何建议。
【问题讨论】:
标签: magento migration magento-1.6
您得到的异常是由客户资源模型的_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
);
}
您的客户已登录,这意味着条件$customer->getId() 为真。但是,由于您遇到了例外情况,我建议您使用相同的电子邮件地址存在重复的客户帐户。
可能是您的导入工具在客户数据中创建了重复项吗?这是我能想到的唯一原因。使用此查询检查您的数据库:
select email, count(*) from customer_entity group by email having count(*) > 1
【讨论】: