Skip to content

Url rewrite not generated for newly assigned category #36295

Closed
@aivorisk

Description

@aivorisk

Preconditions and environment

  • Magento 2.4.4 version
  • PHP versions: 7.4 / 8.1
  • Configurations:
    • Configurations -> Catalog [Catalog tab] -> Search Engine Optimization -> Generate "category/product" URL Rewrites = Yes

Steps to reproduce

  1. Install new magento.
  2. Create a new store view and assign it to a current Store (There should be 2 store views)
  3. Create 2 new categories under root category.
  4. Create a new product and assign a single category to a product.
  5. Edit a product under a first store scope and unselect "Use Default Value" for a "Url key" field in "Search Engine Optimization" tab.
  6. Edit a product under "All store views" scope and assign the 2nd category.

Expected result

All product/category association url rewrites should be generated for the first store view.

Actual result

There is no url rewrite generated for a 2nd assigned category in the first store view.

Additional information

The url rewrite is not generated for newly assigned categories if "Use default value" checkbox is unmarked in a specific store view.

It seems the following code skips url generation for these conditions:
`
public function generateForGlobalScope($productCategories, Product $product, $rootCategoryId = null)
{
$productId = $product->getEntityId();
$mergeDataProvider = clone $this->mergeDataProviderPrototype;

    foreach ($product->getStoreIds() as $id) {
        if (!$this->isGlobalScope($id) &&
            !$this->storeViewService->doesEntityHaveOverriddenUrlKeyForStore(
                $id,
                $productId,
                Product::ENTITY
            )) {
            $mergeDataProvider->merge(
                $this->generateForSpecificStoreView($id, $productCategories, $product, $rootCategoryId)
            );
        }
    }

    return $mergeDataProvider->getData();
}

`

Release note

No response

Triage and priority

  • Severity: S0 - Affects critical data or functionality and leaves users without workaround.
  • Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
  • Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
  • Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
  • Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.

Metadata

Metadata

Assignees

Labels

Area: ProductComponent: UrlRewriteIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedPriority: P2A defect with this priority could have functionality issues which are not to expectations.Progress: PR in progressReported on 2.4.4Indicates original Magento version for the Issue report.Reproduced on 2.4.xThe issue has been reproduced on latest 2.4-develop branch

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions