Magento 2 data migration tool
With the Magento 2 data migration tool it is easy to copy your Magento 1 shop data to a new Magento 2 shop. This tool is quite mighty and helps to reduce migration effort. I tested it for our first migration. Here are my results and experiences.
Magento 2 data migration tool
With Magento 2 data migration tool you can copy quite a lot of data from your old shop. This tool is able to migrate the following:
- orders, invoices, shipments, credit memos
- core configuration
- whishlist, ratings
It is important to know, that this tool only copies data from database. This means, that no media data is copied. For products: all data are available, but no images or data for downloadable products! This tool lacks the following (because of different reasons):
- catalog layout updates
- web api credentials
- admin users and roles
- media files
- custom data and 3rd party data
But what about custom attributes? Let’s find out.
Installation with composer is quite easy. Just run these commands:
composer config repositories.magento composer https://repo.magento.com
composer require magento/data-migration-tool:2.2.2
It is important to set correct Magento 2 version for data migration tool. Check this before installing in your adminhtml. For me it is 2.2.2.
Now you find this tool in your Magento 2 vendor folder: vendor/magento/data-migration-tool
If you installed data migration tool successful, you need to configure it. This tool needs a Magento 2 shop (obviously, because you used already composer on a Magento 2 installation) and a Magento 1 database. You do not need a running Magento 1 shop. This tool copies data from your old Magento 1 database to your new Magento 2 setup. For this you need to configure a couple of things…
You will find all configuration files in this folder: vendor/magento/data-migration-tool/etc/opensource-to-opensource/188.8.131.52
If you are copying filed from community edition to community edition (I suppose you do), the folder is opensource-to-opensource. There are others for all other possibilities. There you find subfolders for all Versions, I will need 184.108.40.206 (yes it is an old shop). This folder contains 2 configuration samples:
If you check this two configuration sample files, you can see, that they are big.
- config.xml.dist has about 150 lines
- map.xml.dist has about 2000 lines
Don’t panik. For a simple migration you do not need to use a full configured file. First we need to create a config.xml file based on this sample, simple copy it to a new filename:
cp config.xml.dist config.xml
Next we need to configure it. You can replace this to the minimum of (just open the file in an editor and change its content):
<?xml version="1.0" encoding="UTF-8"?>
<config xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xs:noNamespaceSchemaLocation="../../config.xsd">
<database host="127.0.0.1" name="magento1" user="root"/>
<database host="127.0.0.1" name="magento2" user="root"/>
You need to configure database connection to your Magento 1 database with host, username and db name. The same is needed for your new Magento 2 database. It is mandatory to put your crypt_key from your Magento 1 shop, to encrypt data in database. You find this in your local.xml of your Magento 1 installation. Please replace my placeholders with your data. It is important that you do not delete lines if you don’t know what you do, otherwise you will get errors if you want to run this migration setting.
Optional you can add following fields:
- Database user password to database tag like:1password="supersecretpassword"
- Table prefix:1<source_prefix>
that you need to add like crypt_key to options tag.
Magento 2 data migration tool offers you another mighty configuration. You can use mappings to define exactly what happens to each table and each column. Further more, you can define own mappings for custom data and 3rd party modules, but for now we use standard Magento migration. Simply copy maps.xml.dist and use standard configuration:
cp maps.xml.dist maps.xml
Magento 2 data migration tool is a gadget to speed up Magento 2 development and helps to migrate an old Magento 1 shop to new version. I showed you how to install it and do a base configuration. Next time I give you details on how to use data migration tool it. Stay tuned!