Category ids are not same as M1

We have already migrated millions of products and data, now we found category id are not same.
We are importing url rewrite from m1 and now it does not work.
We want same categories id same as m1.
Please help.
Also how will it impact the categories that are set on product

  1. Profile photo of Mag MMag M 790.00 $tone September 6, 2019
    Also we are not able to reset step 4

3 answers

Profile photo of Mall Staff 129470.00 $tone September 7, 2019

Hi there,

We want same categories id same as m1.

Because your M2 database always has existing categories. Thus, we can’t keep original Ids for categories it will raises conflict IDs issue on migrating categories.

We are importing url rewrite from m1 and now it does not work.

It seem you haven’t set migrated website/store as default website/store on your M2 instance yet.
Also, on current settings of websites/stores in your site you could do steps below to M2 regenerates URL rewrite for categories and associated products:
1 -- In categories management, create a new root category named ‘Temp Root Category’
2 -- Open Stores management, edit the default Store of the default Website and set the ‘Root Category’ form field to the newly added root category ‘Temp Root Category’ and click Save button.
3 -- Once done, open Stores management once again, edit the default Store of the default Website and set the Root Category form field to the main root category which you want to publish in the storefront again and click Save button.
Magento will regenerates categories and associate products URLs rewrite in this step. It might take sometime to complete this task (It depends on the volume of categories and associated products)
And then, re-index the data and clean the Magento cache.

Profile photo of Mag M 790.00 $tone September 7, 2019

But we have installed fresh magento2 and then performed data migration, so we never had categories on m2.
We want to retain category ids, for marketing purpose, how can we reset and run only categories migration again

Profile photo of ubdev Staff 54840.00 $tone September 9, 2019

Hi there,

 we have installed fresh magento2

As you might know, any fresh M2 always has default categories, thus the Keep original IDs can not be applied to the category.
If you have to keep the original ID for category, you need to follow strictly these steps:
1. Reset data migration from Step 4 to Step 8 (You need to Reset Step 8 first, then reset one by one back to Step 4.)
2. Navigate back to our migration tool admin dashboard, complete all configurations from Step 1 to Step 4.
Note: You should check ‘Merge default websites’ setting in step #2 of our migration tool

3. Next, run the SQL in M2 database (this is used to delete all initial settings of M2):

DELETE FROM catalog_category_entity;

4. Open the PHP file at: pub/ub-tool/protected/controllers/Step4Controller.php
and find the line:

$category2 = new Mage2CatalogCategoryEntity();
$category2->entity_id = NULL;

and replace it with:

$category2 = new Mage2CatalogCategoryEntity();
$category2->entity_id = $category->entity_id;

5. Once done, open your SSH terminal, run data migration from Step 2 to Step 4 using these commands:
php -f bin/ubdatamigration run --step=2;
php -f bin/ubdatamigration run --step=3;
php -f bin/ubdatamigration run --step=4;
6. Back to Stores manager in back-end of your site and set the migrated root category as the Root category of default store of current default website in your M2 instance. And then, reindex the data and clean M2 cache.

Hope that helps.
Ubertheme team


Please login or Register to Submit Answer

Written By