Latest news

Magento 2 Data Migration Guide: Step-By-Step

No comments

In the previous blog post, we have shown you some potential methods to migrate theme from Magento 1 to Magento 2. Today, we will continue giving you a step-by-step guide to Magento 2 Data Migration. As you might know, data transfer is one of the most essential phases in the Magento migration process. A small mistake can lead to serious consequences such as data loss.

In this post, we will show you the way to migrate data from Magento 1 to  Magento 2 by using Magento Data Migration Tool.

What is Magento Data Migration Tool?

The Magento Data Migration gives us an ability to migrate multiple types of data from Magento 1 to Magento 2.

Thanks to this command-line interface, we are able to verify the consistency between db structures of the two Magento versions, follow the transfer progress, creates Magento logs, and make some verification tests.

Moreover, there are three different modes of Magento Data Migration Tool as the followings:

  • Settings mode: This helps to migrate important system configuration settings (e.g.: shipping, payment, tax…) from Magento 1 to Magento 2.
  • Data mode: This helps to migrate main db assets in your database in bulk.
  • Delta mode: This helps to migrate incremental data changes after implementing the two previous modes (e.g.: data added via storefront, order operations in Magento 1 admin panel…)

More specifically, the Magento 2 data migration tool allows us to migrate the following components:

  • Products (core attributes and content) and categories
  • Product ratings and reviews
  • Catalog URL rewrites
  • Customers
  • Orders (related invoices, shipments and credit memos)
  • Attributes and attribute sets
  • Taxes and currencies
  • Catalog and shopping cart price rules
  • User accounts and assigned roles
  • All websites, stores and store views

It’s worth noting that the Magento 2 data migration process doesn’t include:

  • Migration of media files (e.g.: products and categories images, WYSIWYG editor,…)
  • Migration of theme (e.g: Javascript and XML layouts, style sheets,…)
  • Migration of Web services API credentials (e.g.: REST, SOAP, XML-RPC).

 

Preparation for Magento 2 Data Migration

Before we start the migration process, make sure that you have checked the following issues:

  • The Magento Data Migration tool only supports Magento 1.6.0.0 version and over. Hence, if your store is running on the older Magento versions, it’s a must to upgrade it to the latest Magento 1 version before carrying out the data migration process.
  • The Magento 2 data migration process would be easier if your Magento 1 and Magento 2 websites are are on the same MySQL server.
  • You should make a backup of your Magento 1 database to handle possible risks of data loss or damage.
  • You must make sure that your network connection is strong and stable during the database transfer process.
  • You must cease all Magento 1 site’s activities on the backend (except order management) as well as disable all the cron jobs.

 

Magento 2 Data Migration Essential Steps

Step 1: Download and install the Magento Data Migration tool on your Magento 2 website

Remember that your Magento 2 and the Data Migration Tool must be the same version. For instance, if your Magento version is 2.2.5, you must download the Data Migration Tool version 2.2.5.

Now, check your Magento 2 version and then download the corresponding Data Migration Tool here.

Next, to install the downloaded file, you must navigate to your Magento 2 root directory and run the following command:

composer config repositories.data-migration-tool git https://github.com/magento/data-migration-tool
composer require magento/data-migration-tool:<version>

Note: <version> is your Magento 2 codebase version (e.g.: 2.2.5).

After tool installation, all of the mapping and configuration files will be contained in the following directories:

  • For Magento Open Source:

<your Magento 2 install dir>/vendor/magento/data-migration-tool/etc/ce-to-ce

  • For Magento Commerce:

<your Magento 2 install dir>/vendor/magento/data-migration-tool/etc/ce-to-ee

or:

<your Magento 2 install dir>/vendor/magento/data-migration-tool/etc/ee-to-ee

Step 2: Configure Magento 1 and Magento 2 database

  • Firstly, let’s navigate to the path vendor/magento/data-migration-tool/etc/ce-to-ce/<magento1_version>
  • Secondly, you must change the name of the config.xml.dist file to config.xml
  • Thirdly, you must enter the <crypt_key> and other details to access the source and destination database:
<source>
    <database host="db" name="magento1" user="root" password="root"/>
</source>
<destination>
    <database host="db" name="magento2" user="root" password="root"/>
</destination>
<options>
    <crypt_key>sample0123456789</crypt_key>
</options>

The crypt key is found at: <magento1_root_directory>/app/etc/local.xml

The <source> is the Magento 1 database and the <destination> is the Magento 2 database.

Step 3: Migrate the settings – Configure the “settings.xml” file

  • Firstly, let’s navigate to the path vendor/magento/data-migration-tool/etc/ce-to-ce/
  • Secondly, you must alter the settings.xml.dist file name to settings.xml
  • Thirdly, you must copy the settings.xml file into the path vendor/magento/data-migration-tool/etc/ce-to-ce/<magento1_version>
  • Fourthly, let’s modify the <settings_map_file> key tag to the path of settings.xml in the config.xml file & the settings.xml file
  • Fifthly, now you can launch the migration setting tool from the Magento 2 root directory by running the following command:
php bin/magento migrate:settings "vendor\magento\data-migration-tool\etc\ce-to-ce\<magento1_version>\config.xml" --reset

magento data migration

Step 4: Migrate the data – Configure the “configure.xml” file 

  • Firstly, let’s navigate to the path vendor/magento/data-migration-tool/etc/ce-to-ce/<magento1_version>
  • Secondly, you must rename the map.xml.dist file to map.xml
  • Thirdly, you must update the <map_file> tag key to the full path of map.xml in the config.xml file
  • Fourthly, you can launch the migration data tool from the Magento 2 root directory by running the following command:
php bin/magento migrate:data "vendor\magento\data-migration-tool\etc\ce-to-ce\<magento1_version>\config.xml" --reset

magento migration database

how to migrate data from magento 1 to 2Notes: It’s optional to use -r or –reset.

You can do the same for other data migration steps such as map, EAV, customer attributes, log, URL rewrites,…

Your Magento 2 data migration process completed once you completed all of the above steps without any problems.

Next, it’s recommended to flush caches and reindex all indexers in Magento 2 store.

 

Step 5: Migrate incremental changes (optional)

As we have mentioned, the Delta mode is utilized for incremental updates migration since the last time you migrated data. To do that, you have to run the following command:

php bin/magento migrate:delta vendor/magento/data-migration-tool/etc/ce-to-ce/<magento1_version>/config.xml

 

How To Deal With Magento 2 Data Migration Errors?

Here are some common errors when conducting Magento data migration process and solutions:

Error 1: Source documents aren’t mapped: tigren_restorecancelled_order

  • What happens: Some documents (e.g: the tables) can’t be transferred because they don’t belong to Magento’s core tables and need ignoring in the map.xml. 
  • Solution: You need to add the following code snippet to the source <document_rules> tag in the map.xml file:
<ignore>
<document>tigren_restorecancelled_order</document>
</ignore>

Error 2: Source fields aren’t mapped. Document: sales_flat_quote_item. Fields: orderspro_is_temporary?

  • What happens: Quite similar to the first error, here some fields (e.g.: columns) can’t be transferred as they don’t belong to Magento’s core tables and need ignoring in the map.xml. 
  • Solution: You need to add the following code snippet inside the source’s <field_rules> tag in the map.xml file:
<ignore>
<field>sales_flat_quote_item.orderspro_is_temporary</field>
</ignore>

 

Conclusion

As you can see, the database migration from Magento 1 to Magento 2 is a relatively complicated process, which requires a lot of attention and effort. If you don’t have enough knowledge and experience in Magento migration and Magento data migration, in particular, let’s Tigren help you! Contact us now to get a free quotation and consultation for your project – or find more about our Magento migration service here! With more than 5 years of experience in Magento development, we can guarantee your migration success.

Read More:

How Long Does It Take To Conduct Magento 1 to Magento 2 Migration?

Magento Migration Plan For Small E-commerce Businesses

Magento 1 to 2 Migration – Frequently Asked Questions & Answers

Magento 2.2.5 Release – Essential Updates Summary

How To Install SUPEE 10752 With and Without SSH?

 

1 Star2 Stars3 Stars4 Stars5 Stars (93 votes, average: 4.96 out of 5)
Loading...
April LeeMagento 2 Data Migration Guide: Step-By-Step

Related Posts

Leave a Reply

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