diff --git a/app/code/Magento/CatalogInventory/Model/Plugin/ProductLinks.php b/app/code/Magento/CatalogInventory/Model/Plugin/ProductLinks.php index d215145058763..97e805ed92ba1 100644 --- a/app/code/Magento/CatalogInventory/Model/Plugin/ProductLinks.php +++ b/app/code/Magento/CatalogInventory/Model/Plugin/ProductLinks.php @@ -13,15 +13,6 @@ class ProductLinks { - /** - * @var Configuration - */ - private $configuration; - - /** - * @var Stock - */ - private $stockHelper; /** * ProductLinks constructor. @@ -29,13 +20,15 @@ class ProductLinks * @param Configuration $configuration * @param Stock $stockHelper */ - public function __construct(Configuration $configuration, Stock $stockHelper) - { - $this->configuration = $configuration; - $this->stockHelper = $stockHelper; + public function __construct( + private readonly Configuration $configuration, + private readonly Stock $stockHelper + ) { } /** + * Fixes simple products are shown as associated in grouped when set out of stock + * * @param Link $subject * @param Collection $collection * @return Collection @@ -44,7 +37,7 @@ public function __construct(Configuration $configuration, Stock $stockHelper) public function afterGetProductCollection(Link $subject, Collection $collection) { if ($this->configuration->isShowOutOfStock() != 1) { - $this->stockHelper->addInStockFilterToCollection($collection); + $this->stockHelper->addIsInStockFilterToCollection($collection); } return $collection; } diff --git a/app/code/Magento/CatalogInventory/Test/Unit/Model/Plugin/ProductLinksTest.php b/app/code/Magento/CatalogInventory/Test/Unit/Model/Plugin/ProductLinksTest.php index 6cc89ea06af48..4b964848c4c34 100644 --- a/app/code/Magento/CatalogInventory/Test/Unit/Model/Plugin/ProductLinksTest.php +++ b/app/code/Magento/CatalogInventory/Test/Unit/Model/Plugin/ProductLinksTest.php @@ -52,7 +52,7 @@ public function testAfterGetProductCollectionShow($status, $callCount) $this->configMock->expects($this->once())->method('isShowOutOfStock')->willReturn($status); $this->stockHelperMock ->expects($this->exactly($callCount)) - ->method('addInStockFilterToCollection') + ->method('addIsInStockFilterToCollection') ->with($collectionMock); $this->assertEquals($collectionMock, $this->model->afterGetProductCollection($subjectMock, $collectionMock));