Skip to content

[Issue] Prevent Category URL Rewrites generation when no Store Group assigned #32952

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
5 tasks
m2-assistant bot opened this issue May 5, 2021 · 1 comment · Fixed by #32790
Closed
5 tasks

[Issue] Prevent Category URL Rewrites generation when no Store Group assigned #32952

m2-assistant bot opened this issue May 5, 2021 · 1 comment · Fixed by #32790
Assignees
Labels
Component: CatalogUrlRewrite Fixed in 2.4.x The issue has been fixed in 2.4-develop branch Issue: ready for confirmation Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: done Progress: PR in progress Severity: S2 Major restrictions or short-term circumventions are required until a fix is available.

Comments

@m2-assistant
Copy link

m2-assistant bot commented May 5, 2021

This issue is automatically created based on existing pull request: #32790: Prevent Category URL Rewrites generation when no Store Group assigned


Description (*)

During creating new website, Store Group and Store view using php bin/magento setup:upgrade - we got the following issue:
exception was thrown while it was trying to create a new store view that later on will be assigned to Store group, and as result - later on we should generate URLs for this specific store.

This issue happened because, for some reason, we $rootCategoryId as 0 because we don't have any assigned Store Group:

public function getRootCategoryId()
{
if (!$this->getGroup()) {
return Category::ROOT_CATEGORY_ID;
}
return $this->getGroup()->getRootCategoryId();
}

In this case, it was generating URL rewrites for Root categories, that the same URL keys.
Example:

-- Root Category 1 (used on Website 1)
---- Best Sellers (URL key is `best-sellers`)
---- ...
-- Root Category 2 (used on Website 2)
---- ...
---- Best Sellers (URL key is `best-sellers`)
---- ...

In this case, it will try to generate URL rewrites for Root Category 1 and all their children categories + URL rewrites for Root Category 2 and all it's children and will have a conflict due to the same URL key

Related Pull Requests

Fixed Issues (if relevant)

  1. Fixes magento/magento2#<issue_number>

Manual testing scenarios (*)

  1. Create 2 websites, category structure like this:
-- Root Category 1 (used on Website 1)
---- Best Sellers (URL key is `best-sellers`)
---- ...
-- Root Category 2 (used on Website 2)
---- ...
---- Best Sellers (URL key is `best-sellers`)
---- ...
  1. Dump websites/store groups/stores data to the config.php file using php bin/magento app:config:dump scopes command
  2. Create DB dump
  3. Create from the admin a new website, store group, store view, use Root Category 1 for it
  4. Dump websites/store groups/stores data to the config.php file using php bin/magento app:config:dump scopes command
  5. Apply dump from step 3
  6. run php bin/magento setup:upgrade

Expected result:
✔ 3rd website, store group, store view should be created

Actual result:
❌ We have an exception Import failed: URL key for specified store already exists.
image

Questions or comments

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • README.md files for modified modules are updated and included in the pull request if any README.md predefined sections require an update
  • All automated tests passed successfully (all builds are green)
@m2-assistant m2-assistant bot added Component: CatalogUrlRewrite Severity: S2 Major restrictions or short-term circumventions are required until a fix is available. labels May 5, 2021
@m2-community-project m2-community-project bot added the Priority: P2 A defect with this priority could have functionality issues which are not to expectations. label May 18, 2021
@gabrieldagama gabrieldagama added the Fixed in 2.4.x The issue has been fixed in 2.4-develop branch label Jun 16, 2021
@gabrieldagama
Copy link
Contributor

Hi @m2-assistant[bot]. Thank you for your report.
The issue has been fixed in #32790 by @ihor-sviziev in 2.4-develop branch
Related commit(s):

The fix will be available with the upcoming 2.4.3 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: CatalogUrlRewrite Fixed in 2.4.x The issue has been fixed in 2.4-develop branch Issue: ready for confirmation Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: done Progress: PR in progress Severity: S2 Major restrictions or short-term circumventions are required until a fix is available.
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants