Skip to content

Commit 916653c

Browse files
author
Cody Nguyen
committed
need to resave product to reindex it with new configuration.
1 parent 4564bfe commit 916653c

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

dev/tests/api-functional/testsuite/Magento/GraphQl/CatalogInventory/ProductOnlyXLeftInStockTest.php

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
use Magento\Config\Model\ResourceModel\Config;
1111
use Magento\Framework\App\Config\ReinitableConfigInterface;
12+
use Magento\Catalog\Api\ProductRepositoryInterface;
1213
use Magento\Framework\App\Config\ScopeConfigInterface;
1314
use Magento\TestFramework\ObjectManager;
1415
use Magento\TestFramework\TestCase\GraphQlAbstract;
@@ -19,6 +20,10 @@
1920
*/
2021
class ProductOnlyXLeftInStockTest extends GraphQlAbstract
2122
{
23+
/**
24+
* @var ProductRepositoryInterface
25+
*/
26+
private $productRepository;
2227
/**
2328
* @var Config $config
2429
*/
@@ -42,6 +47,7 @@ protected function setUp(): void
4247
parent::setUp();
4348

4449
$objectManager = ObjectManager::getInstance();
50+
$this->productRepository = $objectManager->create(ProductRepositoryInterface::class);
4551
$this->resourceConfig = $objectManager->get(Config::class);
4652
$this->scopeConfig = $objectManager->get(ScopeConfigInterface::class);
4753
$this->reinitConfig = $objectManager->get(ReinitableConfigInterface::class);
@@ -106,13 +112,13 @@ public function testQueryProductOnlyXLeftInStockOutstock()
106112
$productSku = 'simple';
107113
$showOutOfStock = $this->scopeConfig->getValue(Configuration::XML_PATH_SHOW_OUT_OF_STOCK);
108114

109-
$this->resourceConfig->saveConfig(
110-
\Magento\CatalogInventory\Model\Configuration::XML_PATH_SHOW_OUT_OF_STOCK,
111-
1,
112-
ScopeConfigInterface::SCOPE_TYPE_DEFAULT
113-
);
115+
$this->resourceConfig->saveConfig(Configuration::XML_PATH_SHOW_OUT_OF_STOCK, 1);
114116
$this->reinitConfig->reinit();
115117

118+
// need to resave product to reindex it with new configuration.
119+
$product = $this->productRepository->get($productSku);
120+
$this->productRepository->save($product);
121+
116122
$query = <<<QUERY
117123
{
118124
products(filter: {sku: {eq: "{$productSku}"}})

0 commit comments

Comments
 (0)