Skip to content

Commit a44b200

Browse files
committed
MC-35016: Out of stock products doesn't filter properly using "price" filter
1 parent 3926d45 commit a44b200

File tree

1 file changed

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

1 file changed

+34
-0
lines changed

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

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,40 @@ public function testReindexWithCorrectPriority()
159159
$this->assertEquals($childProduct1->getPrice(), $configurableProduct->getMinimalPrice());
160160
}
161161

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+
$configurableProduct1 = $this->productRepository->getById(1, false, null, true);
188+
$stockItem = $configurableProduct1->getExtensionAttributes()->getStockItem();
189+
$stockItem->setIsInStock(Stock::STOCK_OUT_OF_STOCK);
190+
$this->stockRepository->save($stockItem);
191+
192+
$configurableProduct = $this->getConfigurableProductFromCollection(1);
193+
$this->assertEquals(10, $configurableProduct->getMinimalPrice());
194+
}
195+
162196
/**
163197
* Retrieve configurable product.
164198
* Returns Configurable product that was created by Magento/ConfigurableProduct/_files/product_configurable.php

0 commit comments

Comments
 (0)