In this blog, we will check how to Migrate Magento 1 website to Magento 2 with easy steps.
Before starting the migration, please check the below requirements.
- Put Magento 1 store on maintenance mode
- stop all the activities that make any changes in the database.
- Stop all Cron Jobs in Magento 1
- Install & Setup Magento 2.3.3 in your system
- Migrate all your Magento 1 extensions and customizations from version 1 to 2 (you can also find Magento2 extension on the marketplace).
- After installation, take the database backup so it easy to restore.
- We will use Code Migration Tool, which is provided by Magento.
I hope you have already installed & setup Magento 2 website in your system and take the database backup for future use.
Quick Tip:- How to Convert Custom Field From Quote to Order
Now, we will start with the migration, please check below steps:
Step 1: First, download the Data Migration Tool.
Now, go to the newly installed Magento 2 root folder and open the terminal so we can RUN the below command:
/* RUN Command in your terminal and download 2.3.3 version migration tool */ composer require Magento/data-migration-tool:2.3.3
We have installed the latest version 2.3.3 of data migration tool because we have Magento 2.3.3 codebase and it’s necessary
migration tool version match with the version of the Magento 2 codebase.
After RUN the above command it will ask for the public key and your private key for authentication.
To get those keys, just sign in to your Magento eCommerce account and click on My Products > Access Keys. Here, you can easily create and get your keys.
Once, migration tool will installed then you can able to find it on the vendor/Magento folder else you can also download the data migration tool from Github.
Step 2: Now, setup the Data Migration Tool
Now, Under the vendor/Magento/data-migration-tool/etc folder you can see another subfolder:
- ce-to-ce: It holds configuration files and scripts for migrating data from Magento 1 CE to Magento 2 CE
- ce-to-ee: It holds configuration files and scripts for migrating data from Magento 1 CE to Magento 2 EE
- ee-to-ee: It holds configuration files and scripts for migrating data from Magento 1 EE to Magento 2 EE
Now, go to that directory on which you are performing the migration.
For example: ce-to-ce folder
Now, you can see the Magento 1 folders with the version name. If you are migrating to Magento 22.214.171.124 version then you should have to go to the 126.96.36.199 folder
Then, just create the duplicate file of map.xml.dist and rename it to map.xml, in this folder.
Same as you need to create a copy of the file config.xml.dist and rename it to config.xml, in this folder. Open this file and perform the following changes to it:
<source> <database host="magento1host" name="magento1databasename" user="magento1databaseusername" password="magento1password" /> </source> <destination> <database host="magento2host" name="magento2databasename" user="magento2databaseusername" password="magento2password" /> </destination> <options> <source_prefix>magento1-table-sprefix</source_prefix> <dest_prefix>magento2-tables-prefix</dest_prefix> <crypt_key>hk5468jkabe619dae2387df9fs5985241jkh</crypt_key> </options>
1) Required Values:
Under source tag, add the Magento 1 database details, and in the destination add the Magento 2 database details.
The Crypt_key value can be found in the local.xml file which is located in the Magento 1 directory at app/etc/local.xml in the tag.
2) Optional Values:
If you don’t have a prefix for the Magento 1 and Magento 2 tables, then you can leave source prefix fields empty.
Database mapping between Magento 1 and Magento 2 databases is performed through mapping files which are located in:
These files are used for changing the table names, field names, ignoring tables and fields and transferring data of the field to the Magento 2 format.
We need to remove the .dist extension of these files to make use of these mappings.
After removing the .dist from file names, we need to change these file names (removing the .dist) in the config.xml file under the “options” tab.
Here you can see the location of the files that need to be renamed.
/* Original file like this */ <options> <map_file>etc/ce-to-ce/188.8.131.52/map.xml.dist</map_file> <eav_map_file>etc/ce-to-ce/map-eav.xml.dist</eav_map_file> <eav_document_groups_file>etc/ce-to-ce/eav-document-groups.xml.dist</eav_document_groups_file> <eav_attribute_groups_file>etc/ce-to-ce/eav-attribute-groups.xml.dist</eav_attribute_groups_file> <log_map_file>etc/ce-to-ce/map-log.xml.dist</log_map_file> <log_document_groups_file>etc/ce-to-ce/log-document-groups.xml.dist</log_document_groups_file> <settings_map_file>etc/ce-to-ce/settings.xml.dist</settings_map_file> <customer_map_file>etc/ce-to-ce/map-customer.xml.dist</customer_map_file> <customer_document_groups_file>etc/ce-to-ce/customer-document-groups.xml.dist</customer_document_groups_file> <customer_attribute_groups_file>etc/ce-to-ce/customer-attribute-groups.xml.dist</customer_attribute_groups_file> <delta_document_groups_file>etc/ce-to-ce/deltalog.xml.dist</delta_document_groups_file> <order_grids_document_groups_file>etc/ce-to-ce/order-grids-document-groups.xml.dist</order_grids_document_groups_file> <map_document_groups>etc/ce-to-ce/map-document-groups.xml.dist</map_document_groups> <class_map>etc/ce-to-ce/class-map.xml.dist</class_map> </options>
/* After modification in the file, it should be like this */ <options> <map_file>etc/ce-to-ce/184.108.40.206/map.xml</map_file> <eav_map_file>etc/ce-to-ce/map-eav.xml</eav_map_file> <eav_document_groups_file>etc/ce-to-ce/eav-document-groups.xml</eav_document_groups_file> <eav_attribute_groups_file>etc/ce-to-ce/eav-attribute-groups.xml</eav_attribute_groups_file> <log_map_file>etc/ce-to-ce/map-log.xml</log_map_file> <log_document_groups_file>etc/ce-to-ce/log-document-groups.xml</log_document_groups_file> <settings_map_file>etc/ce-to-ce/settings.xml</settings_map_file> <customer_map_file>etc/ce-to-ce/map-customer.xml</customer_map_file> <customer_document_groups_file>etc/ce-to-ce/customer-document-groups.xml</customer_document_groups_file> <customer_attribute_groups_file>etc/ce-to-ce/customer-attribute-groups.xml</customer_attribute_groups_file> <delta_document_groups_file>etc/ce-to-ce/deltalog.xml</delta_document_groups_file> <order_grids_document_groups_file>etc/ce-to-ce/order-grids-document-groups.xml</order_grids_document_groups_file> <map_document_groups>etc/ce-to-ce/map-document-groups.xml</map_document_groups> <class_map>etc/ce-to-ce/class-map.xml</class_map> </options>
Step 3: Now, RUN the migration commands.
1) Now, we will migrate all stores, system configurations, shipping, payment setting, etc.
Open your terminal and RUN below commands:
php bin/magento migrate:settings /var/www/html/magento2/vendor/magento/data-migration-tool/etc/ce-to-ce/220.127.116.11/config.xml
Once the above command is done then you will see the “migration complete” status.
2) Next, you need to run the data migration command:
php bin/magento migrate:data /var/www/html/magento2/vendor/magento/data-migration-tool/etc/ce-to-ce/18.104.22.168/config.xml
The above command will check the consistency of tables and fields between Magento 1 and Magento 2.
If any issue exists, then an error message will appear with a list of all tables and fields that are not mapped.
For example, you face an extension tables error and a particular custom field goes missing in one of the tables. So, to fix this problem you need to install the Magento 2 version of the extensions in the Magento 2 instance so that the missing tables are in the Magento 2 instance database as well.
You can also ignore the tables and fields by adding their entries in map.xml file
After making the entries, the corresponding tables and fields will be ignored and will not be migrated to the Magento 2 database.
Run the migration command again to verify that the issues are fixed.
The data migration is completed once you get the migration complete message.
Step 4: Update new changes via command
Once the migration is completed, if there are any new changes in the database, such as new orders are placed or new reviews are added, then you can migrate that data by running the below command:
php bin/magento migrate:delta /var/www/html/magento2/vendor/magento/data-migration-tool/etc/ce-to-ce/22.214.171.124/config.xml
You can also stop this command by pressing ctrl + C, or else it will keep on running.
Step 5: Final Commands
Now, your database is successfully migrated to Magento 2 and Finally, you need to copy the media files from Magento 1 to Magento 2 then just RUN below commands:
php bin/magento setup:upgrade php bin/magento setup:di:compile php bin/magento setup:static-content:deploy php bin/magento cache:flush php bin/magento indexer:reindex
Now, you can test your new Magento 2 site.
As I am a Magento eCommerce developer, I am wishing you also learn more about Magento website development from here. Explore your Magento development service with trustworthy resources.
Thanks for reading this post!