|
3 | 3 | * Copyright © Magento, Inc. All rights reserved.
|
4 | 4 | * See COPYING.txt for license details.
|
5 | 5 | */
|
| 6 | +declare(strict_types=1); |
| 7 | + |
6 | 8 | namespace Magento\ConfigurableProduct\Model\ResourceModel\Product\Indexer\Price;
|
7 | 9 |
|
8 | 10 | use Magento\Catalog\Api\ProductRepositoryInterface;
|
@@ -157,6 +159,41 @@ public function testReindexWithCorrectPriority()
|
157 | 159 | $this->assertEquals($childProduct1->getPrice(), $configurableProduct->getMinimalPrice());
|
158 | 160 | }
|
159 | 161 |
|
| 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 | + |
160 | 197 | /**
|
161 | 198 | * Retrieve configurable product.
|
162 | 199 | * Returns Configurable product that was created by Magento/ConfigurableProduct/_files/product_configurable.php
|
|
0 commit comments