Skip to content

Commit 87f5b98

Browse files
committed
MC-35016: Out of stock products doesn't filter properly using "price" filter
1 parent 3487aff commit 87f5b98

File tree

1 file changed

+37
-0
lines changed
  • dev/tests/integration/testsuite/Magento/ConfigurableProduct/Model/ResourceModel/Product/Indexer/Price

1 file changed

+37
-0
lines changed

dev/tests/integration/testsuite/Magento/ConfigurableProduct/Model/ResourceModel/Product/Indexer/Price/ConfigurableTest.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
7+
68
namespace Magento\ConfigurableProduct\Model\ResourceModel\Product\Indexer\Price;
79

810
use Magento\Catalog\Api\ProductRepositoryInterface;
@@ -157,6 +159,41 @@ public function testReindexWithCorrectPriority()
157159
$this->assertEquals($childProduct1->getPrice(), $configurableProduct->getMinimalPrice());
158160
}
159161

162+
/**
163+
* Test get product minimal price if all children is out of stock
164+
*
165+
* @magentoConfigFixture current_store cataloginventory/options/show_out_of_stock 1
166+
* @magentoDataFixture Magento/ConfigurableProduct/_files/product_configurable.php
167+
* @magentoDbIsolation disabled
168+
*
169+
* @return void
170+
* @throws \Magento\Framework\Exception\NoSuchEntityException
171+
*/
172+
public function testReindexIfAllChildrenIsOutOfStock(): void
173+
{
174+
$configurableProduct = $this->getConfigurableProductFromCollection(1);
175+
$this->assertEquals(10, $configurableProduct->getMinimalPrice());
176+
177+
$childProduct1 = $this->productRepository->getById(10, false, null, true);
178+
$stockItem = $childProduct1->getExtensionAttributes()->getStockItem();
179+
$stockItem->setIsInStock(Stock::STOCK_OUT_OF_STOCK);
180+
$this->stockRepository->save($stockItem);
181+
182+
$childProduct2 = $this->productRepository->getById(20, false, null, true);
183+
$stockItem = $childProduct2->getExtensionAttributes()->getStockItem();
184+
$stockItem->setIsInStock(Stock::STOCK_OUT_OF_STOCK);
185+
$this->stockRepository->save($stockItem);
186+
187+
$priceIndexerProcessor = Bootstrap::getObjectManager()->get(PriceIndexerProcessor::class);
188+
$priceIndexerProcessor->reindexList(
189+
[$configurableProduct->getId(), $childProduct1->getId(), $childProduct2->getId()],
190+
true
191+
);
192+
193+
$configurableProduct = $this->getConfigurableProductFromCollection(1);
194+
$this->assertEquals(10, $configurableProduct->getMinimalPrice());
195+
}
196+
160197
/**
161198
* Retrieve configurable product.
162199
* Returns Configurable product that was created by Magento/ConfigurableProduct/_files/product_configurable.php

0 commit comments

Comments
 (0)