magento / data-migration-tool

Magento Data Migration Tool
https://devdocs.magento.com/guides/v2.3/migration/bk-migration-guide.html
Open Software License 3.0
334 stars 200 forks source link

a page with "All Store Views" selected cannot be migrated due to url rewrites #856

Open ioweb-gr opened 3 years ago

ioweb-gr commented 3 years ago

Preconditions

  1. Magento 1.9.4.2 and Magento 2.4.1
  2. Php 7.3.22

Steps to reproduce

I'm trying to migrate a website but hitting a volumne check failed error at url rewrites. Apart from the duplicates issue it seems there's an issue with multistore installations when pages are set up like this

image

Normally this works perfectly fine for Magento 1 but in Magento 2, although the pages get migrated correctly with the respective stores selected, the rewrites cannot be created.

Moreover in the backend if you try to save the page with "All Store Views" selected you will get a warning that it conflicts with the rest of the pages.

Expected result

The rewrites get created for this use case.

Actual result

In my example the page with "All Store Views" (ID: 240) got a rewrite created with store_id = 1 and a problem was detected for url rewrite at page cms/page/view/page_id/246 - amphomepage which belongs to store_id 1 in the Magento 1 instance

Moreover if you try to edit them in the backend you cannot. If you edit page 246 and save you will get a message that it will create a duplicate rewrite so cannot be saved and to change the url key. If you edit page 240 you will get a message that it conflicts with all the other pages and that you need to change the url key. I'm not sure why this is happening though. I can see that other pages that were setup with the same key on All store views but without a copy for store_id = 1 do not cause this issue.

Any ideas what the bug is here?

PS: it was hard to detect which was the missing url rewrite inside 700000 url rewrites. I think the migration tool should actually log these issues when they come around when the volume check fails.

I had to add some code to it in order to detect the missing link at \Migration\Step\UrlRewrite\Version191to2000::data

        $sourceRecords = $this->source->getRecords(self::SOURCE, 0, 700000);
        $this->logger->info("Troubleshooting");
        $this->progress->finish();
        $this->progress->start(count($sourceRecords) + count($cmsRecords) + count($destRecords));

        $array1 = [];
        foreach ($sourceRecords as $index => $sourceRecord) {
            $array1[] = implode('--', [$sourceRecord['store_id'], $sourceRecord['target_path'], $sourceRecord['request_path']]);
            $this->progress->advance();
        }

        foreach ($cmsRecords as $index => $cmsRecord) {
            $array1[] = implode('--', [$cmsRecord['store_id'], $cmsRecord['target_path'], $cmsRecord['request_path']]);
        }

        $array2 = [];
        foreach ($destRecords as $index => $destRecord) {
            $this->progress->advance();
            $array2[] = implode('--', [$destRecord['store_id'], $destRecord['target_path'], $destRecord['request_path']]);
        }

        $result = array_diff($array1, $array2);
        if(!empty($result)){
            foreach($result as $page){
                $this->logger->warning(sprintf("Problem detected for url rewrites at page %s", $page));
            }
        }

        $this->progress->finish();

Additional Notes

I'm just assuming here that in Magento 2 when you select the "All Store Views" option it's actually trying to create rewrites for all store views even if page copies exist to cover these store views so it might be a core bug as well. So if I would have

Page ID 240 -> All Store Views Page ID 241 -> store_id = 1 Page ID 242 -> store_id = 4 all with the same url key

When saving the Page ID 240 -> All Store Views it should create a rewrite for store_id 2 and 3 and not try to create for 1 and 4 as well where it will throw an error.

m2-assistant[bot] commented 3 years ago

Hi @ioweb-gr. Thank you for your report. To help us process this issue please make sure that you provided sufficient information.

Please, add a comment to assign the issue: @magento I am working on this