Magento 2 Migration Tool

magento1 magento2 data migration tool

  How to migrate from M1 to M2?

We informed you about the frontend advantages Magento 2 offers, about its new architecture and database design. Additionally, we described a number of improvements that draw users to migrate to Magento 2 platform.

Just to refresh your memory we want to give you a list of such advantages:

  • Changed structure
  • New layout elements
  • CSS Preprocessing
  • Improved performance and scalability
  • Easier to upgrade
  • Less costly
  • Great UX

As you can see, there are many reasons to install a fresh build of Magento 2.

Having presented some of the improvements, we would like to draw your attention to the process of migration from Magento 1 to Magento 2 and the process of upgrading, which are complex enough. To ease them up, Magento released official Data Migration Tool that can help developers transfer store data.

We draw your attention to the fact that it can transfer only data. Themes and customizations of your store can’t be automatically changed on Magento 2. The data migration is based on the number of rules indicated in xml files.

Three official resources are presented below:

So, to help you with this transition, we would like to introduce some simple migration steps.

Installation. Step 1

Download the latest version of Magento 2 from the resources indicated above. You need to set a tool into an empty Magento 2 installation folder with Composer. It’s not an extension, but a stand-alone shell app that requires Magento 2 framework to operate. Its location is: vendor/magento/data-migration-tool/bin/migrate.

To set it up, you need to edit configuration xml files in the vendor/magento/data-migration-tool/etc/ce-to-ce/ folder. On supported default Magento installations, you have to configure source(M1) and destination(M2) database connections in config.xml:

<source>


 <databasehost="localhost"name="magento1_db"user="root"/>


</source>


<destination>


 <databasehost="localhost"name="magento2_db"user="root"/>


</destination>

Composer using makes it easy to integrate third-party components into the code base. In addition, it reduces extension conflicts and compatibility issues, and supports PHP Framework Interoperability standards.

Magento Settings Migration. Step 2 

Taking into account that most of Magento data pertains to websites and stores, you have to migrate settings in the first place.

Magento Data Migration. Step 3

The next is data migration. Such action allows you to transfer categories, products, customers and their orders, wishlists, ratings, etc. We can even turn off such things as logs and quotes. 

Magento Delta Migration. Step 4

Having successfully migrated data, you can always afford just adding new M1 entries to M2 database with delta migration. It will obviously continue where it stopped last time.

At the moment of writing, delta can change and migrate only customers, orders, and another customer related data. It alters or transfers neither  products nor categories.

While carrying out data migration, a set of m2_* tables is created in your M1 database with a set of triggers that permits tracking changes. Here delta is to draw migration time to minimum when going live with M2.

Magento Media Migration. Step 5

After the migration of products and categories, we can copy or paste media files to corresponding places in Magento 2.

Magento Customize Migration. Step 6

For developers, there will be always a need  to configure or customize this tool, as the default Magento does not exist in the real world.We can state that the Magento team has done a good job, since the tool itself is flexible. Besides, the most of mapping is defined through XML files and filtered through PHP classes. 

So, we have custom varchar sales_flat_order.custom_column in M1. If we carry out data migration, we’ll face an error:

[ERROR]: Source fields not mapped. Document: sales_flat_order. Fields: custom_column

To omit it we need to add following to map.xml file

<source>


 <field_rules>


   <ignore>


     <field>sales_flat_order.custom_column</field>


   </ignore>
..

There is a possibility that unknown columns could be ignored by default.To save time, the tool ignores a column in M1 that isn’t defined in xml. We want to move values to renamed custom_column and modify values in the process:

<source>


 <field_rules>


 ..


   <transform>


     <field>sales_flat_order.custom_column</field>


     <handlerclass="\Migration\Handler\AddPrefix">


       <paramname="prefix"value="samecommerce_"/>


     </handler>


   </transform>


   <move>


     <field>sales_flat_order.custom_column</field>


     <to>sales_order.new_custom_column</to>


   </move>


 ..

Example shows that we can use Handler or custom one created to change values on the fly during migration.

It is possible to create the whole new custom step, if mapping isn’t enough. Every step is composed out of Integrity, Data and Volume classes. Integrity is triggered before migration to know whether everything is good with mapping or not. Volume checks if everything is good after migration. The data tool transfers data. And to support delta migrations, delta class can be added.

Conclusion

To sum up, we can state that Magento Migration Tool is a great innovation for migration from Magento 1 to Magento 2. It just needs some kind of customization. It was found that only 1.9.1.0 and 1.9.2.0 were supported. But when M2 comes out, other M1 versions will be supported too.

To learn more about the migration from M1 to M2, contact Sam Ecommerce Magento Development Team!

Comments (1):
Posted on Thursday, March 30, 2017 by :
Nice tutorial, but can you explain how to migrate the customer data(first Name,last name,password_hash etc..)data from Magento 1.X to Magento 2.X as the way of storing this data is changed completely.Now it has a specific column in DB table named "customer_entity" in Magento 2.X but not in Magento 1.X
Leave a comment:
*Your comment will be published after approval by site administrator.