Magento – Magento customer accounts 1 in Magento 2 migrate and apply password

For a project we wanted the customer accounts from a Magento 1 Shop in a new Magento 2 (2.4.2) Import shop. Both shops have two websites each, so the user data comes from two websites. In the new shop, they should also be distributed across the two websites again.

In the first step, the normal export function of Magento 1 all customer accounts exported. Here we can already see the password hashes in the export file.

In the second step, we export the user accounts that have already been created in the new shop for testing purposes (each at least. one per website), the correct field names and values ​​for website, Storeview etc. to see – so the values ​​the Magento 2 expected during import.

I now have the CSV file, which I export through Magento 2 got in Open Office Calc (or Excel) open. In another window the export file from Magento 1. Now I have adjusted the Magento 2 export a little, because not all fields or. Columns needed. I then had the following columns left:

email,_website,_store,created_in,disable_auto_group_change,firstname,group_id,lastname,password_hash,store_id,taxvat,website_id

Now I have copied the values ​​from the M1 file into the M2 file in columns. When all the columns were filled, I saved the file as a new CSV file for import into M2.

Important – In general, always pay attention to the UTF-8 format! The import into M2 then worked without any problems. The accounts were all set up and looked correct. If you tried to use the user name in the frontend / Sign in with email and password, you always got the hint

The account sign-in was incorrect or your account is disabled temporarily. Please wait and try again later.

Annoying! It could have been so easy.

Some searches on google later turned out, that when switching from Magento 1 on Magento 2 the encryption of the passwords from the MD5- has been changed to the SHA256 standard. Therefore, the password hashes in the export from M1 are significantly shorter than those from M2.

Contrary to individual places in the network, the SSH command does NOTHING

php -f bin/magento customer:hash:upgrade

change the imported MD5 encrypted passwords to SHA256, from Magento 2 is downward compatible with MD5. But it can't hurt either – only afterwards the login will still not be possible.

Above SHA256 below MD5

There are now different providers, that offer a software or extension, to carry out the transfer of customer data. There are users too, from adjustments to the code of Magento 2 – Write installation. However, I found a side note, which was too incredible not to have to try. The user “Jack” writes on Stackexchange (Those), that he just one “:0” appended to the MD5 hashes….

After appending “:0” and import before logging in for the first time.
After logging in for the first time.

It's unbelievable but true – you just have to “:0″ append to each MD5 password hash and the login into Magento 2 – Shop works with the old password. Small tip for everyone Excel- / Calc beginner: An auxiliary column with the formula = I2&”:0″ works wonders (“I2” naturally stands for the field with the MD5 hash). You then simply pull the formula downwards. Then copy the column and paste values ​​into the hash column. The auxiliary column can then be removed again.

Published by Covos

Since 2009 I have been working intensively with Magento. I started with the creation and operation of B2C stores. This was extended through my work in the logistics sector. This resulted first specialized B2E systems. Today I work day-a day with exciting B2C, B2B- and B2E projects and reports in this blog about challenges and give insider tips.

Leave a Reply

Your email address will not be published. Required fields are marked *