Skip to content

Commit 526300c

Browse files
committed
ACP2E-84: Mass attribute update creates URL rewrite for wrong store
1 parent 59162f4 commit 526300c

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,11 @@ public function generateForGlobalScope($productCategories, Product $product, $ro
171171
public function generateForSpecificStoreView($storeId, $productCategories, Product $product, $rootCategoryId = null)
172172
{
173173
$mergeDataProvider = clone $this->mergeDataProviderPrototype;
174+
175+
if (!$this->isGlobalScope($storeId) && !$this->isProductBelongToStore($product, $storeId)) {
176+
return $mergeDataProvider->getData();
177+
}
178+
174179
$categories = [];
175180
foreach ($productCategories as $category) {
176181
if (!$this->isCategoryProperForGenerating($category, $storeId)) {
@@ -276,4 +281,15 @@ private function isCategoryRewritesEnabled()
276281
{
277282
return (bool)$this->config->getValue('catalog/seo/generate_category_product_rewrites');
278283
}
284+
285+
/**
286+
* Check if product is available for specified storeId
287+
*
288+
* @param Product $product
289+
* @param int $storeId
290+
* @return bool
291+
*/
292+
private function isProductBelongToStore(Product $product, int $storeId): bool {
293+
return in_array($storeId, $product->getStoreIds());
294+
}
279295
}

0 commit comments

Comments
 (0)