0 votes
1.8k views
in eCommerce by
Prestashop to Magento Customer Password Migration.

Wonder is this even possible? Anyone had some luck doing this?

1 Answer

0 votes
by
To get the migrated passwords from Prestashop to Magento do the below process

Export customers from Prestashop.
Write your own custom query to get the required information from database. Login to Prestashop admin section go to Advanced Parameters->SQL Manager and write a new sql query “select email, firstname, lastname, passwd from ps_customer; “ which will be used to select customers email id, firstname, lastname and password from customer table. If you want to select more fields, write your sql query accordingly. Afterwars export the information in csv file.

Then

The process through which Prestashop and Magento creates customer password is slightly different. Prestashop uses ‘Cookie Key’ prefix to the customer password, which is then MD5 encrypted. Magento uses MD5 and salt at the end. It’s not possible to convert passwords to plain text once it is encrypted using MD5 , so we need to rewrite customer authentication model to extend default validation process and validate passwords imported from Prestashop by adding prefix Cookie Key value to the passwords which was used to generate passwords in Prestashop.

Rewriting Mage_Customer_Model_Customer Model

1. Create a module with namespace Retailon and modulename Customerimport
2. Enable your Module in app/etc/modules/Retailon_Customerimport.xml

<?xml version="1.0"?>
<config>
<modules>
<Retailon_Customerimport>
<active>true</active>
<codePool>local</codePool>
</Retailon_Customerimport>
</modules>
</config>

3. Create config.xml file app/code/local/Retailon/Customerimport/etc/config.xml with following content:

<?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>

4. Create model file app/code/local/Retailon/Customerimport/Model/Customer.php with following content:

<?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;
}
}

5. You will see a long string prepended to the password variable in authenticate method, which is the cookie string used to generate passwords in Prestashop. Go to config/settings.inc.php
file of your Prestashop project’s directory and you will see a line like

define('_COOKIE_KEY_', 'u4qrHpFiADz3peo8rS5tBkWARaa2WqN3qa7XqCI8iddIo7gdbj3KPNzGyK0');

Copy this string and replace the cookie sting of your Magento’s authenticate function.

That’s all you need to do. Now you should be able to login to Magento store using your Prestashop credentials.

Related questions

+1 vote
1 answer 1.8k views
+2 votes
2 answers 9.7k views
+1 vote
2 answers 9.1k views
asked Jan 30, 2018 in Frameworks by Doumeki (480 points)
0 votes
3 answers 3.3k views
0 votes
1 answer 7.4k views
+2 votes
1 answer 1.6k views
...