【发布时间】:2017-07-28 17:36:45
【问题描述】:
我正在将我的商店从 Prestashop 迁移到 Magento。 所以我也想在迁移后保持所有用户的登录详细信息相同。
【问题讨论】:
标签: magento content-management-system prestashop database-migration magento2
我正在将我的商店从 Prestashop 迁移到 Magento。 所以我也想在迁移后保持所有用户的登录详细信息相同。
【问题讨论】:
标签: magento content-management-system prestashop database-migration magento2
**如果您要从 Prestashop 迁移到 Magento,那么最重要的是迁移用户的用户名和密码。如果您将使用此方法,您将能够在迁移后使用相同登录。 **
要让从 Prestashop 迁移到 Magento 的密码正常工作,我们需要执行以下两个步骤:
第 1 步 从 Prestashop 导出客户。
在 Prestashop 中,没有直接的方法来导出客户密码,但您始终可以编写自定义查询以从数据库中获取所需的信息。登录 Prestashop 管理部分,进入 Advanced Parameters->SQL Manager 并编写一个新的 sql 查询“select email, firstname, lastname, passwd from ps_customer; “ 这将用于从客户表中选择客户的电子邮件 ID、名字、姓氏和密码。如果您想选择更多字段,请相应地编写您的 sql 查询。 Afterwars 将信息导出到 csv 文件中。
第 2 步 Prestashop 和 Magento 创建客户密码的过程略有不同。 Prestashop 对客户密码使用“Cookie Key”前缀,然后对其进行 MD5 加密。 Magento 最后使用 MD5 和 salt。使用 MD5 加密后无法将密码转换为纯文本,因此我们需要重写客户身份验证模型以扩展默认验证过程并通过在用于生成密码的密码中添加前缀 Cookie Key 值来验证从 Prestashop 导入的密码在 Prestashop 中。
重写 Mage_Customer_Model_Customer 模型
<?xml version="1.0"?>
<config>
<modules>
<Retailon_Customerimport>
<active>true</active>
<codePool>local</codePool>
</Retailon_Customerimport>
</modules>
</config>
<?xml version="1.0"?>
<config>
<modules>
<Retailon_Customerimport>
<version>0.1.0</version>
</Retailon_Customerimport>
</modules>
<global>
<models>
<customer>
<rewrite>
<customer>Retailon_Customerimport_Model_Customer</customer>
</rewrite>
</customer>
</models>
</global>
</config>
<?php
class Retailon_Customerimport_Model_Customer extends Mage_Customer_Model_Customer {
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) && !$this->validatePassword('u4qrHpFiADz3peo8rS5tBkWARaa2WqN3qa7XqCI8iddIo7gdbj3KPNzGyK0'.$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;
}
}
define('_COOKIE_KEY_', 'u4qrHpFiADz3peo8rS5tBkWARaa2WqN3qa7XqCI8iddIo7gdbj3KPNzGyK0');
复制此字符串并替换 Magento 验证函数的 cookie 字符串。
这就是你需要做的。
现在您应该可以使用您的 Prestashop 凭据登录 Magento 商店了。
阅读愉快!
附:你也可以在这里阅读全文:
Credit:如何将相同的用户名和密码从 Prestashop 转移到 Magento?通过 Ankur Makadia 在网站上 | iOS & Android 应用程序 |游戏 |企业资源规划 |客户关系管理 (https://webappexperts.quora.com/How-can-I-transfer-and-keep-same-Username-Password-from-Prestashop-to-Magento)
【讨论】:
PBKDF2、Rfc2898DeriveBytes、password_hash、Bcrypt、passlib.hash 等函数或类似函数。关键是让攻击者花费大量时间通过蛮力寻找密码。