Skip to content

Commit 20583d7

Browse files
committed
MAGETWO-65133: Integrate the batch algorithm to Stock indexer
1 parent 86da56e commit 20583d7

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

app/code/Magento/CatalogInventory/Model/Indexer/Stock/Action/Full.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,12 @@ public function execute($ids = null)
142142
$select->where('type_id = ?', $indexer->getTypeId());
143143

144144
$entityIds = $this->batchProvider->getBatchIds($connection, $select, $batch);
145-
$indexer->reindexEntity($entityIds);
146-
147-
$select = $connection->select()->from($this->_getIdxTable(), $columns);
148-
$query = $select->insertFromSelect($tableName, $columns);
149-
$connection->query($query);
145+
if (!empty($entityIds)) {
146+
$indexer->reindexEntity($entityIds);
147+
$select = $connection->select()->from($this->_getIdxTable(), $columns);
148+
$query = $select->insertFromSelect($tableName, $columns);
149+
$connection->query($query);
150+
}
150151
}
151152
}
152153
} catch (\Exception $e) {

app/code/Magento/CatalogInventory/Setup/UpgradeSchema.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,11 @@ public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $con
2727

2828
if (version_compare($context->getVersion(), $this->productCompositeKeyVersion, '<')) {
2929
$this->upgradeProductCompositeKey($setup);
30-
$this->addReplicaTable($setup, 'cataloginventory_stock_status', 'cataloginventory_stock_status_replica');
3130
}
3231

32+
if (version_compare($context->getVersion(), '2.3.0', '<')) {
33+
$this->addReplicaTable($setup, 'cataloginventory_stock_status', 'cataloginventory_stock_status_replica');
34+
}
3335
$setup->endSetup();
3436
}
3537

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77
-->
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
9-
<module name="Magento_CatalogInventory" setup_version="2.2.1">
9+
<module name="Magento_CatalogInventory" setup_version="2.3.0">
1010
<sequence>
1111
<module name="Magento_Catalog"/>
1212
</sequence>

0 commit comments

Comments
 (0)