Skip to content

Commit 6d3ab34

Browse files
committed
MAGETWO-47656: [GITHUB] Categories Path for Product URLs not working with anchor #2619
1 parent 3edb2f2 commit 6d3ab34

File tree

1 file changed

+17
-22
lines changed

1 file changed

+17
-22
lines changed

app/code/Magento/CatalogUrlRewrite/Model/Product/AnchorUrlRewriteGenerator.php

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -55,30 +55,25 @@ public function generate($storeId, Product $product, ObjectRegistry $productCate
5555
$anchorCategoryIds = $category->getAnchorsAbove();
5656
if ($anchorCategoryIds) {
5757
foreach ($anchorCategoryIds as $anchorCategoryId) {
58-
try {
59-
$anchorCategory = $this->categoryRepository->get($anchorCategoryId);
60-
$urls[] = $this->urlRewriteFactory->create()
61-
->setEntityType(ProductUrlRewriteGenerator::ENTITY_TYPE)
62-
->setEntityId($product->getId())
63-
->setRequestPath(
64-
$this->urlPathGenerator->getUrlPathWithSuffix(
65-
$product,
66-
$storeId,
67-
$anchorCategory
68-
)
58+
$anchorCategory = $this->categoryRepository->get($anchorCategoryId);
59+
$urls[] = $this->urlRewriteFactory->create()
60+
->setEntityType(ProductUrlRewriteGenerator::ENTITY_TYPE)
61+
->setEntityId($product->getId())
62+
->setRequestPath(
63+
$this->urlPathGenerator->getUrlPathWithSuffix(
64+
$product,
65+
$storeId,
66+
$anchorCategory
6967
)
70-
->setTargetPath(
71-
$this->urlPathGenerator->getCanonicalUrlPath(
72-
$product,
73-
$anchorCategory
74-
)
68+
)
69+
->setTargetPath(
70+
$this->urlPathGenerator->getCanonicalUrlPath(
71+
$product,
72+
$anchorCategory
7573
)
76-
->setStoreId($storeId)
77-
->setMetadata(['category_id' => $anchorCategory->getId()]);
78-
} catch (NoSuchEntityException $e) {
79-
continue;
80-
}
81-
74+
)
75+
->setStoreId($storeId)
76+
->setMetadata(['category_id' => $anchorCategory->getId()]);
8277
}
8378
}
8479
}

0 commit comments

Comments
 (0)