Best practice, tips and tricks for cost-effective migration from Magento 1
Magento 2 Data Migration
It's clear to most that Magento 2 is a far more complex application than Magento 1. With this comes cost, but this need not be the case.
On aggregate, the merchants using MDOQ have staged Magento 2 migrations on average of 50 times for a project. Using automation, this process of 'rinse & repeat' can drastically reduce risk and guarantee success.
Here is an outline of the activities involved in setting up your Magento 2 build project using MDOQ;
- Setup your Magento 2 Connector
- Install the data-migration plugin & configure
- Configure security/access to mySQL on your production server
Setup your Magento 2 Connector
MDOQ Support can assist you with this process if required. Setting up a Live Connector for a production store is easy.
With MDOQ you can complete the whole Magento 2 build project without the need for any production infrastructure!
Install the data-migration plugin
You can install Data Migration tool easily using MDOQ. You need to ensure the version you are installing is the same as the version of Magento 2 you are running.
composer require magento/data-migration-tool:2.3.4
Once installed you can push your changes to source control and configure your scripts.
The next step to get ready to run your migration process involves preparing your configuration config.xml file.
First set your variables for the instance. Copy the the script below but change all the values to those of your Magento 1 site. You only need to do this once if you are going to commit the configuration to source control
You must remember to ensure your website hosting can allow mySQL access into the server on port 3306 from IP address
184.108.40.206. If you are managing your own hosting infrastructure and need more help please review our guide on adding external mySQL access for Magento 2
m1Version=220.127.116.11; m1crypt=XXXXXXXXXX; m1db_database=DATABASE_NAME; m1db_user=DATABASE_USER; m1db_password=DATABASE_PASSWORD; m1db_host=DATABASE_HOST; m1db_prefix=DATABASE_PREFIX;
Then simply copy/paste these commands into the Web SSH terminal
cd ~/htdocs; cp "vendor/magento/data-migration-tool/etc/opensource-to-opensource/$m1Version/config.xml.dist" ./data-migration-config.xml; m2db_host=$(php -r '$env = include "./app/etc/env.php"; echo $env["db"]["connection"]["default"]["host"].PHP_EOL;'); m2db_user=$(php -r '$env = include "./app/etc/env.php"; echo $env["db"]["connection"]["default"]["username"].PHP_EOL;'); m2db_password=$(php -r '$env = include "./app/etc/env.php"; echo $env["db"]["connection"]["default"]["password"].PHP_EOL;'); m2db_database=$(php -r '$env = include "./app/etc/env.php"; echo $env["db"]["connection"]["default"]["dbname"].PHP_EOL;'); sed -i 's/<database host="\localhost\" name=\"magento1\" user=\"root\"/<database host=\"'$m1db_host'\" name=\"'$m1db_database'\" user=\"'$m1db_user'\" password=\"'$m1db_password'\" /g' ./data-migration-config.xml; sed -i 's/<database host=\"localhost\" name=\"magento2\" user=\"root\"/<database host=\"'$m2db_host'\" name=\"'$m2db_database'\" user=\"'$m2db_user'\" password=\"'$m2db_password'\" /g' ./data-migration-config.xml; sed -i 's/<crypt_key \/>/<crypt_key>'$m1crypt'<\/crypt_key> /g' ./data-migration-config.xml; sed -i 's/<source_prefix \/>/<source_prefix>'$m1db_prefix'<\/source_prefix>/g' ./data-migration-config.xml;
Commit this file to source control then you can run the migration as follows
Executing Data Migration as a repeatable process
Most merchants will repeat this process continually so that work can be seperated into separate tasks/instances. This reduces risks and bottlenecks, but also facilitates far better QA to reduce risk of issues when the live migration takes place.
- Create a development instance using MDOQ
- Execute Data Migration Scripts
- Carry out work (customisation/theme/module)
- QA, commit and destroy
Click 'Support' then 'Web SSH' (you must have your SSH key associated with the instance) then click 'Connect'
Run these commands to execute the migration process. You can then carry out your work actitivies and commit your changes before destroying your instance or merging into a UAT instance.
php bin/magento migrate:settings -r -a -vv -- ./data-migration-config.xml php bin/magento migrate:data -r -a -vv -- ./data-migration-config.xml php bin/magento indexer:reindexall;
You should then have a fully functional Magento 2 store, possibly resembling the default Magento theme and possibly in need of some attention cosmetically but theming and features can now be added and your main project can begin.
If you would like to take this to the next level and automate data migration on all new instances in your Magento 2 build project (probably OK if your inventory levels are less than 50k SKUs) then you can implement all the above into MDOQ 'Post Rollup Actions', contact us if you would like to more information.