OK so today we’re doing a little test upgrade of Magento 1 to 2 (2.2 to be precise). Follow along to see what’s involved.
We’re just doing a bare minimal upgrade here so we’ll get an idea of the least that we’ll need to do when performing real upgrades. It’s just a Magento 1.9 basic community install with a minimal amount of data. On real world sites there will likely be a lot more that needs to be done.
I note here that there are four areas that potentially need to be migrated for real-world Magento sites, and only one of these can be done in an automated fashion. The four areas are:
- Data (automated tools exist – see below)
- Themes (must be done manually)
- Extensions (must be done manually by developers)
- Customized code (tools exist but expect lots of manual developer work)
As our little test site doesn’t have any special themes, extensions or customizations, all we need to worry about is the data. If you do have special themes etc. you’ll need someone with design and/or software development (PHP) skills to help.
Data Migration
Let’s get started.
First we need to install Magento 2. This can be a complex process in itself but here’s a guide that simplifies it as much as possible: How to Install Magento 2.
So, we have a blank Magento 2 installation. During the installation process described via the link above we created a Linux user for O/S management of the installation – we called this user “magos”, and will continue to utilize this user in the steps below.
Getting Magento version numbers
We’ll need to know the old version and the new version below. Here’s how we do that:
#Log in as root cd /var/www/magento # the root directory of the old version echo "Version: $(php -r "require 'app/Mage.php'; echo Mage::getVersion();")"
It tells us 1.9.3.1. While we’re here let’s get the version 1 “crypt_key” – we’ll need this soon:
fgrep key app/etc/local.xml
This will give you something like
<key><![CDATA[123456789123456789]]></key>
Make a note of the number.
Now for the new version. For this one we log in as our Magento 2 file system owner first.
#NOTE: Logged in as magos, (the Magento file system owner) cd /var/www/magento2 php /var/www/magento2/bin/magento --version
It tells us 2.2.4.
Now we have enough information to do a basic install and configuration of the Magento 2 data migration tool.
Install the data migration tool
composer config repositories.magento composer https://repo.magento.com composer require magento/data-migration-tool:2.2.4 #NOTE: use the version from above
(NOTE: Composer may prompt for authentication keys. Here’s how to get authentication keys if you don’t have them).
Configure the data migration tool in config.xml
Now we need to create the config.xml file. This will contain most of the settings that control the data migration process. Let’s go to the correct directory:
#NOTE: Logged in as magos, (the Magento file system owner) cd /var/www/magento2/vendor/magento/data-migration-tool/etc/ cd opensource-to-opensource # Do one of these instead if either system is the commerce version: # cd opensource-to-commerce # cd commerce-to-commerce cd 1.9.3.1 #NOTE: This is the old version number we ascertained above
Now we create config.xml from a template supplied with the tool, and start editing it:
cp config.xml.dist config.xml vi config.xml
Specify the old and new databases
Here’s the bare minimum we need to change in config.xml:
<source> <database host="localhost" name="magento" user="root" password="rootPassword"/> </source> <destination> <database host="localhost" name="magento2" user="root" password="rootPassword"/> </destination>
and at the end, the key from version 1 that we retrieved above:
<options> ... <crypt_key>123456789123456789</crypt_key> </options>
Running the data migration tool
Now we’re ready to migrate in earnest. First, the settings:
cd /var/www/magento2/bin ./magento migrate:settings ../vendor/magento/data-migration-tool/etc/opensource-to-opensource/1.9.3.1/config.xml
then the database itself…
./magento migrate:data ../vendor/magento/data-migration-tool/etc/opensource-to-opensource/1.9.3.1/config.xml
…and that’s it! We’re done. Actually, in a real world migration we are likely far from done. Some data has to be manually converted. And as mentioned at the outset, themes, extensions and customisations are generally manual efforts.
If you’re having problems with any of the above, leave a comment below, or contact us for any of your Magento needs.
[…] If you’d like to see how to transfer data from a Version 1 Magento database to your new installation, check out this page: How to upgrade from Magento 1 to Magento 2. […]