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:
- products
- categories
- customers
- 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
Installation with composer is quite easy. Just run these commands:
1 2 | 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
Configuration
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/1.7.0.2
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 1.7.0.2 (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:
1 | 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):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | <?xml version="1.0" encoding="UTF-8"?> <config xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xs:noNamespaceSchemaLocation="../../config.xsd"> <steps> ... </steps> <source> <database host="127.0.0.1" name="magento1" user="root"/> </source> <destination> <database host="127.0.0.1" name="magento2" user="root"/> </destination> <options> ... <crypt_key>my_crypt_key</crypt_key> </options> </config> |
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>
and1<dest_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:
1 | cp maps.xml.dist maps.xml |
Conclusion
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!
Thanks For Your valuable posting, it was very informative.
I’m sure this is fine if it all works smoothly, but what the hell is one supposed to do about a message like this?
My understanding was that I had to install magento then install the tool, but the message seems to suggest i have to un-install it?:
[~/public_html]# composer require magento/data-migration-tool:2.2.7
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
– Installation request for magento/magento2ce 2.2.7 -> satisfiable by magento/magento2ce[2.2.7].
– magento/product-community-edition 2.2.7 requires magento/magento2-base 2.2.7 -> satisfiable by magento/magento2-base[2.2.7].
– don’t install magento/magento2-base 2.2.7|remove magento/magento2ce 2.2.7
– Installation request for magento/product-community-edition 2.2.7 -> satisfiable by magento/product-community-edition[2.2.7].
Installation failed, reverting ./composer.json to its original content.