HowTo: Migrate data from Magento2 Commerce to Magento2 CE

I recently was asked to work on a data migration from Adobe Commerce 2.3.7-p3 to a Magento Community 2.4.3-p2 instance. I have done some data migration work in the past using the official Magento Data Migration Tool so that was my weapon of choice.

Important: It is important to mention that the MDMT was created to migrate data from Magento1 to Magento2 and mainly from Community to Commerce

Still, I decided to carry on using this weapon for the task because in essence the tool:

  • Migrates data from one Magento to another
  • If we think about it, Adobe Commerce db and Magento CE db and almost identical
  • And this is the tool I had experience working with :)

What do you need

  • A source database dump: in this case a database dump of the Adobe Commerce website.
  • The <crypt_key> used in the Adobe Commerce website: this is required if you need to migrate passwords.
  • A local environment with the destination Magento instance.
  • A backup of destination database: You are going reset your destination env multiple times so better be prepared.
  • Patience :)

Notice: If you (or me) are reading this is because you are working on a similar data migration task, so I am going to skip the story part and focus on the steps I did to successfully migrate the data.

Summary

The whole process can be summarised as follows:

  1. Create an empty database into the same server the Magento 2 CE is and import the source database (in this case the Adobe Commerce database).
  2. Install the MDMT in the Magento instance you need to migrate data to.
  3. Extend the MDMT.
  4. Add your configuration to the config.xml.
  5. Run the bin/magento migrate:data -r app/code/Vendor/DataMigrationTool/etc/commerce-to-opensource/2.3.7/config.xml command.
  6. Fix errors.
  7. Run the bin/magento migrate:data -r app/code/Vendor/DataMigrationTool/etc/commerce-to-opensource/2.3.7/config.xml command.
  8. Fix errors.
  9. Post migrating amends in the destination database.

Import the source database

Rather than working with the live site, you can perfectly ask for a stripped and anonymized database dump or the source Adobe Commerce instance. Once you have it, import it into your local MySQL/MariaDB server. (The same server where you have the destination Magento Instance).

Note: If the Source and Destination databases are in different servers, you still use the MDMT by creating an SSH tunnel between the two.

Install the Data Migration Tool

This is pretty straight forward, just use composer to install the MDMT using the version of your destination Magento instance:

composer require "magento/data-migration-tool":"2.4.3"

Extend the MDMT

The MDMT can be customized in 2 ways:

  1. Modify things directly into vendor/magento/data-migration-tool where the data migration is installed.
  2. Create a custom module and extend Magento_DataMigrationTool.

For this job I choose the second approach because I think it is cleaner, it allows me to commit changes to repository, keep track, revert, etc. Also, because the Magento_DataMigrationTool is a Magento module so why not?

So, create an empty module and inside the etc folder create another called commerce-to-opensource

....

Add your configuration

The configuration of the MDMT resides in the config.xml file. Here is where you specify:

  • Source and Destination db credentials.
  • Steps your data migration process will perform.
  • The <crypt_key> used to decode password hashes.
  • And some other settings such as db prefixes, direct table copy, etc.

Run the migrate:data command

Normally you should run the migrate:settings then migrate:data and finally the migrate:delta commands but for this specific case I only needed to migrate Sales and Customers so the other two commands are not needed.

Here is a bit of explanation of what each command does:

migrate:settings

Migrates stores, website and core_config_data.

migrate:data

Migrates pretty much all data except store configuration such as core_config_data. This command also creates db triggers and backlog needed for the migrate:delta command.

migrate:delta

Migrates incremental data. This is useful if for any reason new data (customers, sales, etc) have been created in the source database since the moment you performed the migration.

Related links and resources

Comments

Previous Post