Magento have developed a migration tool to help move data including products, customers, orders and more over to Magento 2. Using the Magento 2 Data Migration Tool requires a few configuration steps. This post will demonstrate using the tool by transferring data from a Magento version 22.214.171.124 store with sample data, to Magento Open Source version 2.2.3.
If you don’t know how sample data is installed on a Magento 1 store, the steps are very straightforward. Simply download a regular version of Magento 1 from the Magento website. In addition, download the sample data zip file from the same Downloads area.
In this example, the code for Magento Open Source version 126.96.36.199 and the sample data for Magento versions 188.8.131.52 and above was downloaded.
Next, a database is created for Magento 184.108.40.206 and before running the install process, import the sample data SQL file into the database.
skin directories that come with the sample data zip file into the Magento 1 codebase and run through the install process.
After installing Magento 220.127.116.11 and importing the sample data script, the database now contains the following data.
Now let’s test out using the Magento 2 Data Migration tool by moving the data across to Magento 2.
In this example, a blank instance of Magento Open Source version 2.2.3 has been installed without any sample data.
Head over to the Magento 2 instance, and within your root directory, run the following commands to download the migration tool from
$ composer config repositories.magento composer https://repo.magento.com $ composer require magento/data-migration-tool:<version>
version should be replaced by the version of the Magento 2 instance. In this example, the command will be the following.
$ composer require magento/data-migration-tool:2.2.3
The migration tool will then reside within the Magento 2 root directory within the
Within the data migration tool directory, there consists an
etc directory containing configuration in regards to the type of migration looking to undertake.
In this example, the configuration within the
opensource-to-opensource directory will be used as this post shows a migration from Open Source version 18.104.22.168 to Open Source version 2.2.3.
Within this directory, more directories exist which are named after the appropriate Magento 1 versions. In this example, the configuration within the
22.214.171.124 directory will be inspected.
The first configuration file to open is the
config.xml.dist file which contains sample configuration of the migration.
config.xml needs to be created in order to run the data migration tool, so copy the contents of
config.xml.dist, create a
config.xml file within the same directory and paste the contents in.
The first thing to configure is the database connections for the Magento 1 and Magento 2 applications. This can be done within the pair of
<source> <database host="localhost" name="magento1" user="root" password="pass" /> </source> <destination> <database host="localhost" name="magento2" user="root" password="pass" /> </destination>
<crypt_key> needs to be passed in as a parameter. This key comes from Magento 1, and is found within the
app/etc/local.xml file within the
<source> <database host="localhost" name="magento1" user="root" password="pass" /> </source> <destination> <database host="localhost" name="magento2" user="root" password="pass" /> </destination> <options> <source_prefix>magento1</source_prefix> <crypt_key>dbd95b9104e8a97dc0d4accf3c6f5b8f</crypt_key> </options>
<source_prefix> node is used to contain the Magento 1 database table prefix if a prefix was used. This option does not need to be included if you did not use a table prefix.
To run the data migration tool, within your Magento project root directory, run the following command.
$ /path/to/your/php bin/magento migrate:data --reset vendor/magento/data-migration-tool/etc/opensource-to-opensource/126.96.36.199/config.xml
188.8.131.52 directory to the directory of the version of Magento 1 you are trying to migrate the data from. The
--reset argument is especially useful as it starts the migration from the beginning. This argument is mainly used for testing migration and any potential errors.
When using the Magento 2 Data Migration tool, there is quite a strong possibility that it won’t run without errors the first time it is run. This might be because of errors such as
Source documents are not mapped and
Source fields are not mapped.
Errors may occur because of entities that exist in Magento do not exist in the Magento 2 database. This can be due to installing extensions on Magento 1 that haven’t been installed on the newer version.
It is worth checking out the Data Migration Troubleshooting page and articles on the web to try and diagnose and resolve any issues that you might have.
Using the Magento 2 Data Migration tool provided by Magento has proven to be extremely useful when needing to move data from Magento 1 to Magento 2. Considering that a simple upgrade from Magento 1 to 2 was not possible because of the architectural differences in the codebases, this is a great solution to help merchants transfer their data.
Note: This article is based on Magento Open Source version 2.2.3.