Magento data migration using Data migration tool – command line

/
/
335 Views

As you know that Magento 2 different from Magento 1 and you can’t direct update your Magento 1 store to Magento 2 using any patch or extension or folder merge.
You have to migrate all data and extension using migration tool which is provided by Magento itself.
Here in this tutorial, I will show you that how to migrate your data (order, customers, product and category and other all Magento settings and data) to Magento 2.

migrate magento 2

Note: Magento migration tool only migrates only Magento data to Magento 2.it’s not migrate any 3rd party extension or theme settings.

Magento migration tool migrates M1 database to M2 database using some set of rules which are defined in the XML files.

Steps of migration

There are three modes of transfer that migrate data from your Magento 1 store to Magento 2.

Step 1: Setting Migration

• Data: Stores, Websites, And System Configuration

• Code: bin/magento migrate:settings [-r|–reset] {<path to config.xml>}

Step 2: Data Migration

• Data: Catalogs, Customers, And Orders,

• Code: bin/magento migrate:data [-r|–reset] {<path to config.xml>}

Step 3: Delta Migration

• Data: Same As Data Migration

• Code: bin/magento migrate:delta [-r|–reset] {<path to config.xml>}Let’s start the migration

Step 1. Download the Migration tool

Option 1: You can download migration tool using composer with the following command.

Run this command in your Magento 2 root directory

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

Option 2: direct download the migration tool from Git and place it into magento 2 folder
Git link https://github.com/magento/data-migration-tool

Step 2: Select your Magento version and Database linking

Frist find out your Magento 1 version (you can check in admin at the footer) and then go to the following folder in the Magento 2
vendor/magento/data-migration-tool/etc

Here you can see 3 different folder

1.commerce-to-commerce – for enterprise to enterprise edition migration

2.opensource-to-commerce – for community to enterprise edition migration

3. opensource-to-opensource – for community to community edition migration

Now select your folder according to your edition and go to inside of the folder where you will see the all available version of magento and select your version ( magento migration tool support only 1.6+ version only)

For my version selected

opensource-to-opensource/1.9.3.8

Now rename config.xml.dist file to config.xml and open it in your favorite editor.

in this file you have to add the database information of both M1 and M2 server with M2 encryption key which you can get from M1 local.xml file.

copy the following code and paste it into the config.xml file and change the name of database user name, password and host.

<source>

<database host="localhost" name="magento111" user="root" password="admin"/>

</source>

<destination>

<database host="localhost" name="magento222" user="root" password="admin"/>

</destination>

Paste the following code before starting the <options> node in the xml file.

Now copy your M1 encription key and paste in the config.xml in the <options>

<crypt_key>689ed8eb975b49dd31bb4828e60e1e87</crypt_key>

Now if you have prefix in M1 database then add following line in the options node <source_prefix>mage_</source_prefix>

If you have prefix in magento 2 then copy and paste this line in the options node

<dest_prefix>mage2_ </dest_prefix >

Step 3: Settings Migration

Run following command in terminal at magento 2 root

php bin/magento migrate:settings –reset vendor/magento/data-migration-tool/etc/opensource-to-opensource/1.6.2.0/config.xml

Here path of config.xml file wiil be changed according to your magento version.Please change it before run

Step 4: Data Migration

Run following command in terminal at magento 2 root

php bin/magento migrate:data –reset vendor/magento/data-migration-tool/etc/opensource-to-opensource/1.6.2.0/config.xml

Here path of config.xml file wiil be changed according to your magento version.Please change it before run

Step 5. Magento 2 flush and reindex Magento 2

Run the following command to flush and re-index the data in Magento 2

Now you have successfully migrated Magento 1 to Magento 2.

Step 6. Migrated media

Media files can simply be copy/pasted to appropriate places in M2 after products and categories are migrated, simple as that.

Troubleshooting

If you have any custom field in any table then you have to ignore those custom field in Magento 2.You can add those fields to the map.xml fle.

For example
If you have following error
[ERROR]: Source documents are not mapped tm_testimonials_store

You have to add this into map.xml to ignore it
Example

<source>
<document_rules>
<ignore>
<document>find_feed_import_codes</document>
</ignore>

[ERROR]: Source fields not mapped. Document: sales_flat_order. Fields: custom_column
To ignore it we need to add the following to map.xml file.
<source>

<field_rules>

<ignore>

<field>sales_flat_order.custom_column</field>

</ignore>

Sign up for our newsletter to get Daily Updates

It is main inner container footer text