migrate from magento 1 to magento 2

Today I will help you to migrate from Magento 1(M1) to Magento 2(M2).
  • Magento 2 has completely new structure then Magento 1 and also lot's of new advanced security features.
  • Magento 2 support PHP Version 7 and faster then Magento 1.
  • There are many new features in Magento 2.
  • Magento has end the support for Magento 1. This is one of the major reason to switch your M1 store to magento 2.
Now This is the right time for Migrate your M1 store to M2 store.

Please follow the below steps for migration
Let's do it.

1. First We need to do basic setup of Magento 2.


  •  Download latest magento and then setup magento 2 in your local system
  • We need to download M1 database and setup into phpmyadmin in your local system
  •  Copy your M1 store media to M2 pub/media
        M1 path:   root /media
M2 path:   root /pub/media    

2. Now check your M2 version. We can check version using below command. 

      
        command:  
       
  php bin/magento –version
  
 

3. After version check, we will try to install data migration tool in M2 store. I am giving you commands for install tool in M2 store. Please check


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

  • When you fire this command, Magento may asked for enter your Magento authentication keys.
  • Public key is your username and private key is your password.
  • You can get those key from your magento marketplace account.

4. After migration tool installed in our M2 store, We start to configure Migration Tool using below commands.


       
   php bin/magento migrate:settings -r path to config.xml


  •  The path variable in above command in which you need to add config.xml of your M1 store. If your M1 store version is 1.8.1.0 then simply go to this version directory in your migration tool and find your config,xml
  • Please check below example.
  • Command:

       
  php  bin/magento migrate:settings -r vendor/magento/data-migration-tool/etc/ce-to-ce/1.8.1.0/config.xml

  • config.xml is your M1 version. You can find your xml in data-migration-tool directory.
  • Please check below screen shot :
migration config

    I will explain you above image folder names.
    A) Magento Open Source:

  • If you can go to this path "<your Magento 2 install dir>/vendor/magento/data-migration-tool/etc/", you will get "opensource-to-opensource" directory and this folder contain the Configuration and scripts for migrating from Magento Open Source 1 to Magento Open Source 2
    B) Magento Commerce:

  • If you can go to this path "<your Magento 2 install dir>/vendor/magento/data-migration-tool/etc/", you will get "opensource-to-commerce" directory and this folder contain the Configuration and scripts for migrating from Magento Open Source 1 to Magento Commerce 2
  • You will also get "commerce-to-commerce" directory using this path "<your Magento 2 install dir>/vendor/magento/data-migration-tool/etc/".  This folder contain the Configuration and scripts for migrating from Magento Commerce 1 to Magento Commerce 2

  • First you need to decide that your both magento  stores type like open source, commerce. and then select one of the folder.
  • For example:  If your magento 1 and Magento 2 stores are open source then go to "opensource-to-opensource" directory" and then select M1 version folder.
You can select one of this version folder based on your Magento 1 store version. If your M1 store version is 1.8.1.0 then select this folder under the opensource-to-opensource.

Please check screen shot :
migrate from m1 to m2

5. Before we proceed further, Please take backup of M2 store.


6. Let's Configure M1 Database with Migration Tool


  • For configure M1 Database, we need to go below path.

      Example: vendor/magento/data-migration-tool/etc/<M1-to-M2 edition>/M1 version

      Let's say <M1-to-M2 edition> is opensource-to-opensource and M1 version is 1.8.1.0.
      So final path is <Magento 2 root dir>/vendor/magento/data-migration-tool/etc/opensource-to-opensource/1.8.1.0

  • Rename a config file from config.xml.dist to config.xml in above location.
  • Now open config.xml in a your editor and update M1 and M2 database configuration as per the following:
    <source>
<database host="localhost" name="Magento1-DB-name" user="DB-username" password="DB-password"/>
    </source>
    <destination>
<database host="localhost" name="Magento2-DB-name" user="DB-username" password="DB-password"/>
    </destination>
    <options>
<crypt_key>Magento1-Encrypted-Key(find from local.xml)</crypt_key>
    </options>

  •   In above code source node or tag declare magento 1 database information and destination node declare magento 2 database information
  •   <crypt_key> is mandatory node. crypt_key> is the encryption key of Magento 1 store and can be found in the <Magento 1 root dir>/app/etc/local.xml file.
  •   The last is Save the config.xml file.

 

7. Maping Configuration


  • For change configuration of mapping, you need to go below path.

        vendor/magento/data-migration-tool/etc/<M1-to-M2 edition>/M1 version

        For example : <Magento 2 root dir>/vendor/magento/data-migration-tool/etc/opensource-to-opensource/1.8.1.0
  • Copy and Rename  file from map.xml.dist to map.xml in above path.
  • Set map file path in config.xml. Please check below screen shot:
magento 1 to 2 migration

    Note :  i have set map file path from "commerce-to-commerce" directory in above screen shot. You can set as per your requirement.

  • If you want to remove some table when migration then you can add in ignore tags those tables in map.xml.
  • The map.xml file read when the map step is running in migration and this is responsible for transfering data from M1 store to M2 Store.
  • This file contain the mapping between data structures of source (Magento 1) and destination (Magento 2). 
=> For example if our Magento 1 store contains tables or fields that belong to some extension and and that tables or fields does not available in Magento 2, then these tables or fields need to be added here to ignore them by Map file Otherwise it will show an error message in map step.

Note : if you facing any issue during migration like "Source or destination documents are not mapped", "source fields are not mapped" then just go to map.xml and ignore those fields which are not mapped with M2 store.

8. After mapping step done, Now we are ready to migrate and fire below migration command.



Run Migration Data Tool:

php  bin/magento migrate:data -r path to config.xml
   
    Command:  
       
 php  bin/magento migrate:data -r vendor/magento/data-migration-tool/etc/opensource-to-opensource/1.8.1.0/config.xml



That's it. Now migration is started.
if an error show during migration, it stops the process and resumes from the last state.The success message is displayed on terminal when the data migration successfully completed.