magento / magento/data-migration-tool

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

Open
#856 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PHP
Stars
339
Forks
195
PR merge metrics
No merged PRs in 30d

Description

### 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](https://user-images.githubusercontent.com/20220341/97091053-8ed5e580-1641-11eb-93ed-58f3e7590d2c.png)

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`

```php
$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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with Migration\Step\UrlRewrite\Version191to2000::data and trace how source, CMS, and destination URL rewrite records are compared during the volume check. Reproduce the All Store Views case with store-specific page copies, then verify that migration completes without conflicting rewrites and that missing links are reported clearly.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
database, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.