Skip to content

Commit 3e8c25b

Browse files
committed
Merge remote-tracking branch 'origin/MC-19331' into 2.2.10-develop-pr112
2 parents 3a9444b + 1f1a2c6 commit 3e8c25b

File tree

4 files changed

+22
-290
lines changed

4 files changed

+22
-290
lines changed

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

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Magento\Framework\DB\Adapter\AdapterInterface;
1212
use Magento\CatalogInventory\Api\StockConfigurationInterface;
1313
use Magento\CatalogInventory\Model\Indexer\Stock\Action\Full;
14+
use Magento\Catalog\Model\Product\Attribute\Source\Status as ProductStatus;
1415

1516
/**
1617
* CatalogInventory Default Stock Status Indexer Resource Model
@@ -225,6 +226,8 @@ protected function _getStockStatusSelect($entityIds = null, $usePrimaryTable = f
225226
{
226227
$connection = $this->getConnection();
227228
$qtyExpr = $connection->getCheckSql('cisi.qty > 0', 'cisi.qty', 0);
229+
$metadata = $this->getMetadataPool()->getMetadata(\Magento\Catalog\Api\Data\ProductInterface::class);
230+
$linkField = $metadata->getLinkField();
228231

229232
$select = $connection->select()->from(
230233
['e' => $this->getTable('catalog_product_entity')],
@@ -238,6 +241,12 @@ protected function _getStockStatusSelect($entityIds = null, $usePrimaryTable = f
238241
['cisi' => $this->getTable('cataloginventory_stock_item')],
239242
'cisi.stock_id = cis.stock_id AND cisi.product_id = e.entity_id',
240243
[]
244+
)->joinInner(
245+
['mcpei' => $this->getTable('catalog_product_entity_int')],
246+
'e.' . $linkField . ' = mcpei.' . $linkField
247+
. ' AND mcpei.attribute_id = ' . $this->_getAttribute('status')->getId()
248+
. ' AND mcpei.value = ' . ProductStatus::STATUS_ENABLED,
249+
[]
241250
)->columns(
242251
['qty' => $qtyExpr]
243252
)->where(
@@ -308,8 +317,7 @@ protected function _updateIndex($entityIds)
308317
}
309318

310319
/**
311-
* Delete records by their ids from index table.
312-
*
320+
* Delete records by their ids from index table
313321
* Used to clean table before re-indexation
314322
*
315323
* @param array $ids
@@ -354,8 +362,6 @@ public function getIdxTable($table = null)
354362
}
355363

356364
/**
357-
* Get status expression
358-
*
359365
* @param AdapterInterface $connection
360366
* @param bool $isAggregate
361367
* @return mixed
@@ -381,8 +387,6 @@ protected function getStatusExpression(AdapterInterface $connection, $isAggregat
381387
}
382388

383389
/**
384-
* Get stock configuration
385-
*
386390
* @return StockConfigurationInterface
387391
*
388392
* @deprecated 100.1.0
@@ -398,8 +402,6 @@ protected function getStockConfiguration()
398402
}
399403

400404
/**
401-
* Get query processor composite
402-
*
403405
* @return QueryProcessorComposite
404406
*/
405407
private function getQueryProcessorComposite()

dev/tests/integration/testsuite/Magento/Catalog/_files/products_with_layered_navigation_attribute.php

Lines changed: 0 additions & 172 deletions
This file was deleted.

dev/tests/integration/testsuite/Magento/Catalog/_files/products_with_layered_navigation_attribute_rollback.php

Lines changed: 0 additions & 51 deletions
This file was deleted.

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

Lines changed: 12 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -5,42 +5,24 @@
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-
178
/**
189
* Full reindex Test
1910
*/
20-
class FullTest extends TestCase
11+
class FullTest extends \PHPUnit\Framework\TestCase
2112
{
2213
/**
23-
* @var ObjectManagerInterface
24-
*/
25-
private $objectManager;
26-
27-
/**
28-
* @var Processor
14+
* @var \Magento\CatalogInventory\Model\Indexer\Stock\Processor
2915
*/
3016
protected $_processor;
3117

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

4125
/**
42-
* Reindex all
43-
*
4426
* @magentoDbIsolation disabled
4527
* @magentoAppIsolation enabled
4628
* @magentoDataFixture Magento/Catalog/_files/product_simple.php
@@ -49,9 +31,13 @@ public function testReindexAll()
4931
{
5032
$this->_processor->reindexAll();
5133

52-
$categoryFactory = $this->objectManager->get(CategoryFactory::class);
53-
/** @var ListProduct $listProduct */
54-
$listProduct = $this->objectManager->get(ListProduct::class);
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+
);
5541

5642
$category = $categoryFactory->create()->load(2);
5743
$layer = $listProduct->getLayer();
@@ -75,37 +61,4 @@ public function testReindexAll()
7561
$this->assertEquals(100, $product->getQty());
7662
}
7763
}
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()
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-
}
11164
}

0 commit comments

Comments
 (0)