Skip to content

Commit 6375772

Browse files
committed
BUG#AC-2535: Url rewrites are all removed when mass updating visibility on store view when set to not visible indivudually
1 parent 1f69f02 commit 6375772

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

app/code/Magento/CatalogUrlRewrite/Model/Products/AdaptUrlRewritesToVisibilityAttribute.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ public function __construct(
7070
*/
7171
public function execute(array $productIds, int $visibility, int $storeId): void
7272
{
73+
echo'afdsdv'; var_dump($storeId);
7374
$products = $this->getProductsByIds($productIds, $storeId);
7475

7576
/** @var Product $product */
@@ -79,6 +80,7 @@ public function execute(array $productIds, int $visibility, int $storeId): void
7980
[
8081
UrlRewrite::ENTITY_ID => $product->getId(),
8182
UrlRewrite::ENTITY_TYPE => ProductUrlRewriteGenerator::ENTITY_TYPE,
83+
UrlRewrite::STORE_ID => $storeId,
8284
]
8385
);
8486
} elseif ($visibility !== Visibility::VISIBILITY_NOT_VISIBLE) {

dev/tests/integration/testsuite/Magento/CatalogUrlRewrite/Observer/ProcessUrlRewriteOnChangeVisibilityObserverTest.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,7 @@ public function testMakeProductInvisibleViaMassAction()
6767

6868
/** @var StoreManagerInterface $storeManager */
6969
$storeManager = $this->objectManager->get(StoreManagerInterface::class);
70-
$storeManager->setCurrentStore(0);
71-
70+
$firstStore = current($product->getStoreIds());
7271
$testStore = $storeManager->getStore('test');
7372
$productFilter = [
7473
UrlRewrite::ENTITY_TYPE => 'product',
@@ -80,7 +79,7 @@ public function testMakeProductInvisibleViaMassAction()
8079
'target_path' => "catalog/product/view/id/" . $product->getId(),
8180
'is_auto_generated' => 1,
8281
'redirect_type' => 0,
83-
'store_id' => '1',
82+
'store_id' => $firstStore,
8483
],
8584
[
8685
'request_path' => "product-1.html",
@@ -100,12 +99,14 @@ public function testMakeProductInvisibleViaMassAction()
10099
'catalog_product_attribute_update_before',
101100
[
102101
'attributes_data' => [ ProductInterface::VISIBILITY => Visibility::VISIBILITY_NOT_VISIBLE ],
103-
'product_ids' => [$product->getId()]
102+
'product_ids' => [$product->getId()],
103+
'store_id' => $firstStore
104104
]
105105
);
106106

107107
$actual = $this->getActualResults($productFilter);
108-
$this->assertCount(0, $actual);
108+
//Initially count was 2, when visibility of 1 store view is set to not visible individually, the new count is 1
109+
$this->assertCount(1, $actual);
109110
}
110111

111112
/**

0 commit comments

Comments
 (0)