Magento2 Data Migration and tips to solve error during migration

By vijayramiUpdated 5 October 2022
Data MigrationMagento2

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


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>
crypt_keyapp/etc/local.xml

<source_prefix>===</source_prefix>

<direct_document_copy>1</direct_document_copy>
direct_document_copy1

map.xmlmap-customer.xmlclass-map.xmlvendor/magento/data-migration-tool/etc/opensource-to-opensource/1.9.4.2/config.xml
vendor/magento/data-migration-tool/etc/opensource-to-opensource/1.9.4.2/map.xml.distvendor/magento/data-migration-tool/etc/opensource-to-opensource/1.9.4.2/map.xml


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



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

  1. Settings
  2. Data
  3. Delta
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


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>
Magento2 Data Migration and tips to solve error during migration | Vijay M. Rami