Magento2 | PWA | GraphQL

Magento2 Data Migration and tips to solve error during migration


Magento2 Provides data migration tool to Migrate data from Magento1 to Magento2. 

All the data migration related information you can find on Magento devdocs migration guide.

In this post i just cover the basic information and some tips to solve the error during migration task.

Install Data migration tool.

composer require magento/data-migration-tool

Create new database and upload your Magento1 store's sql file in that newly created magento1 database. 

take back up or dump your Magento 1 and Magento 2 database as soon as possible. This allows you to restore the initial database state if migration is not successful.

Now go to vendor/magento/data-migration-tool/etc/opensource-to-opensource directory.

Here you will find different Magento1 version's folder.

Check your magento1 version and go into that folder accordingly.

Let's say my Magento1 version is 1.9.4.4. so i will go into that folder.

copy config.xml.dist file and paste it into same directory by renaming it with config.xml 

i.e. config.xml.dist ==> config.xml

Add your magento1 and Magento2 database configuration settings in that file by modifying below code:
<source>
  <database host="127.0.0.1" name="magento1" user="root" password="" />
</source>
<destination>
  <database host="127.0.0.1" name="magento2" user="root" password="" />
</destination>
Also change in crypt_key node by adding your crypt_key from Magento1. You will find it from app/etc/local.xml file.
====================================
You can also add if your magento1 database have prefix.
<source_prefix>===</source_prefix>
You can also set <direct_document_copy> to 1 for better performance.
<direct_document_copy>1</direct_document_copy>
Set direct_document_copy as 1 will direct copy data from database, but 'source' and 'destination' databases MUST be placed on the same MySQL instance and 'destination' user MUST be granted with 'SELECT' permissions on 'source' database.

Now Check map.xml, map-customer.xml and class-map.xml file path in vendor/magento/data-migration-tool/etc/opensource-to-opensource/1.9.4.2/config.xml as per below:

  etc/opensource-to-opensource/1.9.4.4/map.xml
  etc/opensource-to-opensource/map-customer.xml
  etc/opensource-to-opensource/class-map.xml

Copy file from vendor/magento/data-migration-tool/etc/opensource-to-opensource/1.9.4.2/map.xml.dist and paste it into same folder by renaming it to vendor/magento/data-migration-tool/etc/opensource-to-opensource/1.9.4.2/map.xml

Copy file from
vendor/magento/data-migration-tool/etc/opensource-to-opensource/class-map.xml.dist
vendor/magento/data-migration-tool/etc/opensource-to-opensource/map-customer.xml.dist

and paste into same folder by renaming it to

vendor/magento/data-migration-tool/etc/opensource-to-opensource/class-map.xml
vendor/magento/data-migration-tool/etc/opensource-to-opensource/map-customer.xml

Magento Data Migration Tool operates in three modes: 
  1. Settings: migrates configuration settings.
  2. Data: bulk migrates main data in the database.
  3. Delta: transfers incremental data updates, added to Magento 1 storefront and Admin Panel while running previous migration modes.
To start migrating settings, run:

php bin/magento migrate:settings vendor/magento/data-migration-tool/etc/opensource-to-opensource/1.9.4.2/config.xml

To start migrating data, run:

php bin/magento migrate:data vendor/magento/data-migration-tool/etc/opensource-to-opensource/1.9.4.2/config.xml

After running this command we are facing many errors. In this article we will discuss about these errors and its solutions.

Error:
Source fields are not mapped. Document: sales_flat_order. Fields: c2q_internal_quote_id 
Source fields are not mapped. Document: sales_flat_quote. Fields: proposal_quote_id

To solve this kind of error we will add c2q_internal_quote_id and proposal_quote_id  into ignore field of source field rules in map.xml file.
<source>
<field_rules>
<ignore>
 <field>sales_flat_order.c2q_internal_quote_id</field>
</ignore>
<ignore>
 <field>sales_flat_quote.proposal_quote_id</field>
</ignore>
</field_rules>
</source>
Error:

Source documents are not mapped: am_shopby_page,am_shopby_range, ....

To solve this kind of error we will add am_shopby_filter and am_shopby_page  into ignore field of document rules rules in map.xml file.
<source>
<document_rules>
<ignore>
 <document>am_shopby_filter</document>
</ignore>
<ignore>
 <document>am_shopby_page</document>
</ignore>
</document_rules>
</source>
Error:

Incompatibility in data. Source document: eav_attribute. Field: source_model. Error: Class not2order/source_alloworder is not mapped in record attribute_id=173

To solve this kind of error we will add not2order/source_alloworder class into rename field of classmap in class-map.xml file.
<rename>
 <from>not2order/source_alloworder</from>
 <to></to>
</rename>
Error:

Integrity constraint violation: 1062 Duplicate entry '9-product-details' for key 'EAV_ATTRIBUTE_GROUP_ATTRIBUTE_SET_ID_ATTRIBUTE_GROUP_CODE' 

if this type of error can not solved then you have to run migration again. So, please it is must necessary that you have take a backup of database for both Magento1 and Magento2 before start the migration.

Error:

Communication link failure: 1153 Got a packet bigger than 'max_allowed_packet' bytes.

To solve this type of error you need to define max_allowed_packet value in your php.ini file to 2 to 3 times higher than current value.

Error:

Type Error occurred when creating object: Magento\\Eav\\Model\\Entity\\Attribute\\Source\\Config","1":"#1 Magento\\Framework\\ObjectManager\\Factory\\Compiled->create('Magento\\Eav\\Mode...', array()) called at [vendor\/magento\/framework\/ObjectManager\/ObjectManager.php:56]

This kind of error specifically display when you navigate to All customers list, order list or Produuct list. this error occur because you have created custom attribute for customer, product or order and that attributes source model class is not found as per magento database.

To solve this error first you have to found which kind of custom attributes you have defined in your Magento1 database with custom sql script.

after that check in eav_attribute table for that attribute.

If you don't know your custom attribute name then search for `select` value in `frontend_input` column. then check for the source_model column value. its value should not be null or empty or it fills with correct class. 

You can set value for frontend_input column to int if you wanna work on the source_model later. 

And still your error can't solve then set `frontend_input` column value to 'text' and set class name in source_model column to null if you don't have correct class name.

Sometimes you can also add your custom attribute for customer in map-customer.xml file in ignore field.
<source>
<field_rules>
<ignore>
 <field>customer_entity.assigned_sales_rep</field>
</ignore>
</field_rules>
</source>
here i have cover almost all major points and erros when you are doing data migration job. Hope you like this article and find some useful tips 😀
0 Comments On "Magento2 Data Migration and tips to solve error during migration"

Back To Top