Skip to content

Commit 5ebf4c0

Browse files
committed
MAGETWO-83204: "Hide from Product Page" option does not work for child of configurable product
1 parent 4226a55 commit 5ebf4c0

File tree

3 files changed

+13
-17
lines changed

3 files changed

+13
-17
lines changed

app/code/Magento/Catalog/Model/Product.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1058,7 +1058,7 @@ protected function _afterLoad()
10581058
*/
10591059
public function cleanCache()
10601060
{
1061-
return parent::cleanModelCache();
1061+
return $this->cleanModelCache();
10621062
}
10631063

10641064
/**

app/code/Magento/ConfigurableProduct/Model/Plugin/ProductIdentitiesExtender.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,20 +38,19 @@ public function __construct(Configurable $configurableType, ProductRepositoryInt
3838
* Add parent identities to product identities
3939
*
4040
* @param Product $subject
41-
* @param \Closure $proceed
41+
* @param array $identities
4242
* @return array
4343
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
4444
*/
45-
public function aroundGetIdentities(Product $subject, \Closure $proceed)
45+
public function afterGetIdentities(Product $subject, $identities)
4646
{
47-
$identities = $proceed();
47+
$identities = (array) $identities;
4848

4949
foreach ($this->configurableType->getParentIdsByChild($subject->getId()) as $parentId) {
5050
$parentProduct = $this->productRepository->getById($parentId);
51-
$identities = array_merge($identities, $parentProduct->getIdentities());
51+
$identities = array_merge($identities, (array) $parentProduct->getIdentities());
5252
}
53-
$identities = array_unique($identities);
5453

55-
return $identities;
54+
return array_unique($identities);
5655
}
5756
}

app/code/Magento/ConfigurableProduct/Test/Unit/Model/Plugin/ProductIdentitiesExtenderTest.php

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,29 +41,26 @@ protected function setUp()
4141
$this->plugin = new ProductIdentitiesExtender($this->configurableTypeMock, $this->productRepositoryMock);
4242
}
4343

44-
public function testAroundGetIdentities()
44+
public function testAfterGetIdentities()
4545
{
46+
$productId = 1;
4647
$productIdentity = 'cache_tag_1';
4748
$productMock = $this->getMockBuilder(Product::class)
4849
->disableOriginalConstructor()
4950
->getMock();
50-
$proceed = function () use ($productIdentity) {
51-
return [$productIdentity];
52-
};
53-
54-
$productId = 1;
5551
$parentProductId = 2;
5652
$parentProductIdentity = 'cache_tag_2';
53+
$parentProductMock = $this->getMockBuilder(Product::class)
54+
->disableOriginalConstructor()
55+
->getMock();
56+
5757
$productMock->expects($this->once())
5858
->method('getId')
5959
->willReturn($productId);
6060
$this->configurableTypeMock->expects($this->once())
6161
->method('getParentIdsByChild')
6262
->with($productId)
6363
->willReturn([$parentProductId]);
64-
$parentProductMock = $this->getMockBuilder(Product::class)
65-
->disableOriginalConstructor()
66-
->getMock();
6764
$this->productRepositoryMock->expects($this->once())
6865
->method('getById')
6966
->with($parentProductId)
@@ -72,7 +69,7 @@ public function testAroundGetIdentities()
7269
->method('getIdentities')
7370
->willReturn([$parentProductIdentity]);
7471

75-
$productIdentities = $this->plugin->aroundGetIdentities($productMock, $proceed);
72+
$productIdentities = $this->plugin->afterGetIdentities($productMock, [$productIdentity]);
7673
$this->assertEquals([$productIdentity, $parentProductIdentity], $productIdentities);
7774
}
7875
}

0 commit comments

Comments
 (0)