Skip to content

Commit b73fcd2

Browse files
committed
Merge remote-tracking branch 'origin/MC-17919' into 2.3-develop-pr28
2 parents 291ddcf + f91d1cb commit b73fcd2

File tree

2 files changed

+59
-20
lines changed
  • app/code/Magento/CatalogInventory/Model/ResourceModel/Indexer/Stock
  • dev/tests/integration/testsuite/Magento/CatalogInventory/Model/Indexer/Stock/Action

2 files changed

+59
-20
lines changed

app/code/Magento/CatalogInventory/Model/ResourceModel/Indexer/Stock/DefaultStock.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,6 @@ protected function _getStockStatusSelect($entityIds = null, $usePrimaryTable = f
230230
{
231231
$connection = $this->getConnection();
232232
$qtyExpr = $connection->getCheckSql('cisi.qty > 0', 'cisi.qty', 0);
233-
$metadata = $this->getMetadataPool()->getMetadata(\Magento\Catalog\Api\Data\ProductInterface::class);
234-
$linkField = $metadata->getLinkField();
235233

236234
$select = $connection->select()->from(
237235
['e' => $this->getTable('catalog_product_entity')],
@@ -245,12 +243,6 @@ protected function _getStockStatusSelect($entityIds = null, $usePrimaryTable = f
245243
['cisi' => $this->getTable('cataloginventory_stock_item')],
246244
'cisi.stock_id = cis.stock_id AND cisi.product_id = e.entity_id',
247245
[]
248-
)->joinInner(
249-
['mcpei' => $this->getTable('catalog_product_entity_int')],
250-
'e.' . $linkField . ' = mcpei.' . $linkField
251-
. ' AND mcpei.attribute_id = ' . $this->_getAttribute('status')->getId()
252-
. ' AND mcpei.value = ' . ProductStatus::STATUS_ENABLED,
253-
[]
254246
)->columns(
255247
['qty' => $qtyExpr]
256248
)->where(

dev/tests/integration/testsuite/Magento/CatalogInventory/Model/Indexer/Stock/Action/FullTest.php

Lines changed: 59 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,42 @@
55
*/
66
namespace Magento\CatalogInventory\Model\Indexer\Stock\Action;
77

8+
use Magento\TestFramework\Helper\Bootstrap;
9+
use Magento\Framework\ObjectManagerInterface;
10+
use Magento\CatalogInventory\Model\Indexer\Stock\Processor;
11+
use Magento\Catalog\Model\CategoryFactory;
12+
use Magento\Catalog\Block\Product\ListProduct;
13+
use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory;
14+
use Magento\Catalog\Model\Product;
15+
use PHPUnit\Framework\TestCase;
16+
817
/**
918
* Full reindex Test
1019
*/
11-
class FullTest extends \PHPUnit\Framework\TestCase
20+
class FullTest extends TestCase
1221
{
1322
/**
14-
* @var \Magento\CatalogInventory\Model\Indexer\Stock\Processor
23+
* @var ObjectManagerInterface
24+
*/
25+
private $objectManager;
26+
27+
/**
28+
* @var Processor
1529
*/
1630
protected $_processor;
1731

32+
/**
33+
* @inheritdoc
34+
*/
1835
protected function setUp()
1936
{
20-
$this->_processor = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(
21-
\Magento\CatalogInventory\Model\Indexer\Stock\Processor::class
22-
);
37+
$this->objectManager = Bootstrap::getObjectManager();
38+
$this->_processor = $this->objectManager->get(Processor::class);
2339
}
2440

2541
/**
42+
* Reindex all
43+
*
2644
* @magentoDbIsolation disabled
2745
* @magentoAppIsolation enabled
2846
* @magentoDataFixture Magento/Catalog/_files/product_simple.php
@@ -31,13 +49,9 @@ public function testReindexAll()
3149
{
3250
$this->_processor->reindexAll();
3351

34-
$categoryFactory = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(
35-
\Magento\Catalog\Model\CategoryFactory::class
36-
);
37-
/** @var \Magento\Catalog\Block\Product\ListProduct $listProduct */
38-
$listProduct = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(
39-
\Magento\Catalog\Block\Product\ListProduct::class
40-
);
52+
$categoryFactory = $this->objectManager->get(CategoryFactory::class);
53+
/** @var ListProduct $listProduct */
54+
$listProduct = $this->objectManager->get(ListProduct::class);
4155

4256
$category = $categoryFactory->create()->load(2);
4357
$layer = $listProduct->getLayer();
@@ -61,4 +75,37 @@ public function testReindexAll()
6175
$this->assertEquals(100, $product->getQty());
6276
}
6377
}
78+
79+
/**
80+
* Reindex with disabled product
81+
*
82+
* @return void
83+
* @magentoDbIsolation disabled
84+
* @magentoAppIsolation enabled
85+
* @magentoDataFixture Magento/Catalog/_files/products_with_layered_navigation_attribute.php
86+
*/
87+
public function testReindexAllWithDisabledProduct(): void
88+
{
89+
$productCollectionFactory = $this->objectManager->get(CollectionFactory::class);
90+
$productCollection = $productCollectionFactory
91+
->create()
92+
->addAttributeToSelect('*')
93+
->addAttributeToFilter('sku', ['eq' => 'simple3'])
94+
->addAttributeToSort('created_at', 'DESC')
95+
->joinField(
96+
'stock_status',
97+
'cataloginventory_stock_status',
98+
'stock_status',
99+
'product_id=entity_id',
100+
'{{table}}.stock_id=1',
101+
'left'
102+
)->load();
103+
104+
$this->assertCount(1, $productCollection);
105+
106+
/** @var Product $product */
107+
foreach ($productCollection as $product) {
108+
$this->assertEquals(1, $product->getData('stock_status'));
109+
}
110+
}
64111
}

0 commit comments

Comments
 (0)