Skip to content

Commit c947017

Browse files
committed
MAGETWO-70651: Saving category create not valid url-rewrites
1 parent 495d0c4 commit c947017

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

app/code/Magento/CatalogUrlRewrite/Model/CategoryBasedProductRewriteGenerator.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
use Magento\Catalog\Model\Category;
99
use Magento\Catalog\Model\Product;
10-
use Magento\Store\Model\Store;
1110
use Magento\Catalog\Model\Product\Visibility;
1211

1312
/**
@@ -47,11 +46,19 @@ public function generate(Product $product, Category $category, $rootCategoryId =
4746

4847
$storeId = $product->getStoreId();
4948

49+
$productCategories = $product->getCategoryCollection()
50+
->addAttributeToSelect('url_key')
51+
->addAttributeToSelect('url_path');
52+
5053
$urls = $this->productScopeRewriteGenerator->isGlobalScope($storeId)
51-
? $this->productScopeRewriteGenerator->generateForGlobalScope([$category], $product, $rootCategoryId)
54+
? $this->productScopeRewriteGenerator->generateForGlobalScope(
55+
$productCategories,
56+
$product,
57+
$rootCategoryId
58+
)
5259
: $this->productScopeRewriteGenerator->generateForSpecificStoreView(
5360
$storeId,
54-
[$category],
61+
$productCategories,
5562
$product,
5663
$rootCategoryId
5764
);

0 commit comments

Comments
 (0)