Skip to content

Commit 188ecb3

Browse files
committed
8624: Stock status not coming back after qty update
1 parent 15928fb commit 188ecb3

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

dev/tests/integration/testsuite/Magento/Catalog/Model/ProductTest.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,7 @@ public function testSaveWithDifferentQty()
557557
{
558558
//if save (out of stock product with qty 0) with new qty > 0 it should become in stock.
559559
//if set out of stock for product with qty > 0 it should become out of stock
560-
$product = $this->productRepository->get('simple-out-of-stock');
560+
$product = $this->productRepository->get('simple-out-of-stock', true, null, true);
561561
$stockItem = $product->getExtensionAttributes()->getStockItem();
562562
$this->assertEquals(false, $stockItem->getIsInStock());
563563
$stockData = [
@@ -567,7 +567,11 @@ public function testSaveWithDifferentQty()
567567
$product->setStockData($stockData);
568568
$product->save();
569569

570-
$product = $this->productRepository->get('simple-out-of-stock');
570+
/** @var \Magento\CatalogInventory\Model\StockRegistryStorage $stockRegistryStorage */
571+
$stockRegistryStorage = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
572+
->get(\Magento\CatalogInventory\Model\StockRegistryStorage::class);
573+
$stockRegistryStorage->removeStockItem($product->getId());
574+
$product = $this->productRepository->get('simple-out-of-stock', true, null, true);
571575
$stockItem = $product->getExtensionAttributes()->getStockItem();
572576
$this->assertEquals(true, $stockItem->getIsInStock());
573577
$stockData = [
@@ -577,7 +581,8 @@ public function testSaveWithDifferentQty()
577581
$product->setStockData($stockData);
578582
$product->save();
579583

580-
$product = $this->productRepository->get('simple-out-of-stock');
584+
$stockRegistryStorage->removeStockItem($product->getId());
585+
$product = $this->productRepository->get('simple-out-of-stock', true, null, true);
581586
$stockItem = $product->getExtensionAttributes()->getStockItem();
582587
$this->assertEquals(false, $stockItem->getIsInStock());
583588
}

0 commit comments

Comments
 (0)