Presentation is loading. Please wait.

Presentation is loading. Please wait.

Tips and tricks in Magento 2 data migration tool

Similar presentations


Presentation on theme: "Tips and tricks in Magento 2 data migration tool"— Presentation transcript:

1 Tips and tricks in Magento 2 data migration tool
Razvan Avramescu - Magento Developer, Toptal • 549,144 Current Magento 1 Customers. This means over half of million online websites according to BuiltWith Technology Lookup. Does anyone knows or guess how many Magento 2 projects are active on the internet according to the same tool reports? 105,554 Current Magento 2 Customers. Magento 1 end of life was recently moved from 2018 to June 2020 and as we can see, we can basically expect quite a significant amount of migrations. I am going to talk about tips and tricks when using the officially Magento data migration tool, which I hope will help other people during their planification, their data import from legacy magento 1 and later on with the issues they might appear after a successful completion.

2 Overview What is data migration tool
Data Migration Tool is a command-line interface used for transferring data from Magento 1 to Magento 2. It does not include any custom code migration which is a different step when moving from old system to the new one. It can a better alternative for basic export / import functionality and it should deal better with some the logic changes, for example creating url rewrites using the new framework technique. Overview What is data migration tool? Well, Data Migration Tool is a command-line interface used for transferring data from Magento 1 to Magento 2. Data migration is part of a larger scenario, for example it does not include any custom code migration which is a different step when moving from old site to the new one. It can a better alternative for basic csv export / import functionality and it should deal better with some of the logic changes, for example creating url rewrites using the new framework technique. Some other options/alternatives are: Ubertheme Magento 2 data migration and to create a Custom own written solution. The Ubertheme works pretty good, it does the job, it has a nice web interface, but it seems a little bit slower than official Magento migration tool, which means that it might not be first option when dealing with large amount of data.

3 Definitions Source Destination New Magento 2 database. Document Field
Old Magento 1 database. Destination New Magento 2 database. Document MySQL Table Field MySQL Column Definitions Source, destination, document, field

4 Before you start Magento 1 Magento 2 Backup live database.
Always use a copy of live database to test the setup. If your media are stored in the database, use synchronize in Storage Configuration. Magento 2 Read magento documentation and pay attention to every detail. If you want to use Delta for bringing updates later on, use the live db, assuming setup was very well tested. Before you start Backup live database. Always use a copy of live database to test the migration setup. If you media are stored to database, run synchronize from Storage Configuration for Media section in the admin panel. Read carefully magento documentation and pay attention to all the detail such starting by using a fresh Magento 2 installation and not after it was customized, because it cannot be migrated on top of existing data. Make sure you understand the way the tool works. For example if you wish to bring updates after you are done with the new site and let's say you prepare to go live, then you must know that the delta is creating source database triggers to mark new/updated entities into newly created during data migration m2_* prefixed tables and will use that info to see what have been changed in Magento 1 after the last run. Considering that the above scenario applies to you it means that you will need to use the live database. As I mentioned earlier, as a safety measure, first you need to test your migration using a copy of the database located on the same MySQL instance as Magento 2 and use direct_document_copy to speed up things.

5 What to expect Expected Unexpected
Reserve time for it and prepare it, is not actually a few hours task. Ensure you have enough resources get familiar with terms such as `max_allowed_packet` and `wait_timeout`. Unexpected There might be issues with source data. There might be issues with migrated data. What to expect Reserve time for it and prepare it, is not actually a few hours task. Ensure your new machine has enough resources, adjust MySQL options such as `max_allowed_packet` and `wait_timeout` to avoid possible script interruptions. Probably you might want to teak php as well. There might be issues with source data. You need to stop doing any changes in backend during the process. There will be issues with migrated data.

6 Main data to be migrated
Entities Products Categories (and its products relations) Customers Orders Configurations CMS elements Websites, Store groups, Stores Media assets for Products, Categories, CMS Main data to be migrated - Products - Categories (and its products relations) - Customers - Orders - Configurations - CMS elements - Websites, Store groups, Stores - Media assets for Products, Categories, CMS

7 Some data must be transformed
Besides the transformation logic handle by the tool, there might be other data that must be transformed Values must be changed to match Magento 2 new classes models (namespace). Some values must be nulled even if are empty for consistency in the destination. Also some attributes are now required. Besides the transformation logic handle by the tool, such as renamed/removed tables/columns, there might be other data that must be transformed: - Values must be changed to match Magento 2 new classes models (namespace) - Some values must be nulled even if are empty for consistency in the destination. Also some attributes are now required.

8 Schedule

9 Install fresh magento copy and data migration tool
Run migration Settings, Data and Delta in this exact order. Regression test against CRUD operations and system configuration I II III IV V Configure migration Backup Magento 2 Start by installing a magento 1 copy and a clean Magento 2 project. Data migration tool can be installed in a different centralized system with access to both databases, important is that the versions are the same as in the destination project. You should have all the time the online documentation opened ( Configure migration based on source and destination version. Documentation is also very clear here ( When you are running Migration tool from a centralized system and you use a different destination database, this way you could have multiple projects to migrate and you can reuse some of the configuration files. You start by having a different config.xml for each project and you can load from there different other setup files. The command-line tool allows to specify which configuration file should be used when you execute it. There are preconfigured sample (`*.dist`) files which should be used as reference. Run migration settings, backup. Run migration data, backup. Do a test by updating Magento 1 entity data, check migration Delta, backup. Once the migration is completed, first we might wanna check CRUD operations in admin panel for the newly migrated entities and make a list with all the issues we might discover.

10 Next steps Fix system configurations errors if any
It might worth the time to actually restore a clean installation system configuration. Check Magento 2 github issue tracker Sometimes can save debug time. Bring Media files Media folder needs to be copied manually. Saving system configuration might fail. The system configuration could include values pointing to unexisting objects. It could actually save time if you revert core_config_data to blank magento installation and try to make the settings manually from the admin, this way you basically review the new setup, a lot of things actually changed from version 1 to version 2. So spend time to see the admin configuration. You have FPC using Varnish, you have elasticsearch in Catalog Search as option in Magento 2.3 Community Edition. I believe it worths trying! It might also speed up things. Another issue which it might appear is caused by attributes set names. The real fix is very fast by updating the name in the database table, while Magento 2 expects “Price” and not “Migrated Price”. This can actually be time consuming to debug it. I suggest you should dig first magento github issue tracker because probably you are not the first one dealing with the same error and situation, which can save some other time while finding a proper fix/resolution. If you do not find a solution fast, probably you want to extend the error messages for that particular problem and see the exact cause and find a solution on your own. This requires some more advanced programming skills. If the images were stored to database, it requires to synchronization from admin panel, in the Storage Configuration for Media section. Otherwise just a copy from old Magento 1 to new Magento 2 media folder it does the whole job.

11 Tips Data migration should be the first task, over a clean Magento 2 installation. Take the errors during migration as something helpful to the process. Use -vvv for extended debugging. Magento 1 instance can be live during migration, especially if you need later on to bring delta (updates). Some of the attributes might be required in M2 and are not in M1 (telephone). Data migration should be the first task, over a clean Magento 2 installation. Take the errors during migration as something helpful to the process. While running the tools you basically discover all the documents/fields that needs to be mapped. Use -vvv for extended debugging. Magento 1 instance can be live during migration, especially if you need later on to bring delta (updates). Make sure you succeed first with a clone. Some of the attributes might be required in M2 and are not in M1, such as the telephone.

12 Tips Backup mysql database in the process before any step.
A good idea is to script repeatable process: drop database, create database, import database backup. The versions of the Data Migration Tool and Magento must exactly match. Do not upgrade Magento 2 until migration is complete. Use -r to restart process. Backup mysql database in the process before any step. A good idea is to script repeatable process: drop database, create database, import database backup. The versions of the Data Migration Tool and Magento must exactly match. Do not upgrade Magento 2 until migration is complete. Do not do any changes in Magento 1 when migration process runs. Use -r to restart process. Sometimes it might throw a new error because the previous executions, step in which you probably better do a database magento 2 restore and start over after you try to fix and avoid the same issue from happening.

13 Tips Create separate from core data-migration config files.
Try not to delete entities in Magento 2 until you finish with migration, running Delta might not work. The last but not the least, Make sure you do not lose the configuration files until you go live with Magento 2. Create separate from core data-migration config files. Try not to delete entities in Magento 2 until you finish with migration, running Delta might not work. The last but not the least, Make sure you do not lose the configuration files until you go live with Magento 2. We mentioned earlier that you can have a centralized system with migration tool especially if you plan to migrate multiple projects.

14 Setup next goals Migrate extensions and custom code. Migrate themes.
Migrate customizations. Run delta if you want to bring Magento 1 updates (backup first). Setup next goals Migrate extensions and custom code. Migrate themes. Migrate customizations. Run delta if you want to bring Magento 1 updates (backup first).

15 Thank you!


Download ppt "Tips and tricks in Magento 2 data migration tool"

Similar presentations


Ads by Google