Skip to content

Commit f5f7b0b

Browse files
committed
Merge remote-tracking branch 'origin/MC-30357' into 2.4-develop-pr11
2 parents 1f5987e + 153688a commit f5f7b0b

File tree

4 files changed

+58
-0
lines changed

4 files changed

+58
-0
lines changed

app/code/Magento/CatalogInventory/etc/mview.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
<view id="cataloginventory_stock" class="Magento\CatalogInventory\Model\Indexer\Stock" group="indexer">
1010
<subscriptions>
1111
<table name="cataloginventory_stock_item" entity_column="product_id" />
12+
<!--Track product status to trigger stock indexer-->
13+
<table name="catalog_product_entity_int" entity_column="entity_id" />
1214
</subscriptions>
1315
</view>
1416
<view id="catalog_product_price" class="Magento\Catalog\Model\Indexer\Product\Price" group="indexer">

dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ProductTest.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2968,4 +2968,34 @@ public function testProductStockStatusShouldBeUpdated()
29682968
$status = $stockRegistry->getStockStatusBySku('simple');
29692969
$this->assertEquals(Stock::STOCK_IN_STOCK, $status->getStockStatus());
29702970
}
2971+
2972+
/**
2973+
* Test that product stock status is updated after import on schedule
2974+
*
2975+
* @magentoDataFixture mediaImportImageFixture
2976+
* @magentoDataFixture Magento/Catalog/_files/product_simple.php
2977+
* @magentoDataFixture Magento/CatalogImportExport/_files/cataloginventory_stock_item_update_by_schedule.php
2978+
* @magentoDbIsolation disabled
2979+
*/
2980+
public function testProductStockStatusShouldBeUpdatedOnSchedule()
2981+
{
2982+
/** * @var $indexProcessor \Magento\Indexer\Model\Processor */
2983+
$indexProcessor = $this->objectManager->create(\Magento\Indexer\Model\Processor::class);
2984+
/** @var $stockRegistry StockRegistry */
2985+
$stockRegistry = $this->objectManager->create(StockRegistry::class);
2986+
/** @var StockRegistryStorage $stockRegistryStorage */
2987+
$stockRegistryStorage = $this->objectManager->get(StockRegistryStorage::class);
2988+
$status = $stockRegistry->getStockStatusBySku('simple');
2989+
$this->assertEquals(Stock::STOCK_IN_STOCK, $status->getStockStatus());
2990+
$this->importDataForMediaTest('disable_product.csv');
2991+
$indexProcessor->updateMview();
2992+
$stockRegistryStorage->clean();
2993+
$status = $stockRegistry->getStockStatusBySku('simple');
2994+
$this->assertEquals(Stock::STOCK_OUT_OF_STOCK, $status->getStockStatus());
2995+
$this->importDataForMediaTest('enable_product.csv');
2996+
$indexProcessor->updateMview();
2997+
$stockRegistryStorage->clean();
2998+
$status = $stockRegistry->getStockStatusBySku('simple');
2999+
$this->assertEquals(Stock::STOCK_IN_STOCK, $status->getStockStatus());
3000+
}
29713001
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
use Magento\CatalogInventory\Model\Indexer\Stock\Processor;
9+
use Magento\TestFramework\Helper\Bootstrap;
10+
11+
/** * @var $indexerProcessor Processor */
12+
$indexerProcessor = Bootstrap::getObjectManager()->get(Processor::class);
13+
$indexerProcessor->getIndexer()->setScheduled(true);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
use Magento\CatalogInventory\Model\Indexer\Stock\Processor;
9+
use Magento\TestFramework\Helper\Bootstrap;
10+
11+
/** * @var $indexerProcessor Processor */
12+
$indexerProcessor = Bootstrap::getObjectManager()->get(Processor::class);
13+
$indexerProcessor->getIndexer()->setScheduled(false);

0 commit comments

Comments
 (0)