Skip to content

Commit f957039

Browse files
author
lestare
committed
MAGETWO-65324: [Backport] - [Performance] Join to product entity table cause locks on order page/api - for 2.1.6
1 parent 54c2a0e commit f957039

File tree

1 file changed

+13
-3
lines changed
  • app/code/Magento/CatalogInventory/Model/ResourceModel

1 file changed

+13
-3
lines changed

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

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,23 @@ public function lockProductsStock($productIds, $websiteId)
125125
return [];
126126
}
127127
$itemTable = $this->getTable('cataloginventory_stock_item');
128-
$productTable = $this->getTable('catalog_product_entity');
129128
$select = $this->getConnection()->select()->from(['si' => $itemTable])
130-
->join(['p' => $productTable], 'p.entity_id=si.product_id', ['type_id'])
131129
->where('website_id=?', $websiteId)
132130
->where('product_id IN(?)', $productIds)
133131
->forUpdate(true);
134-
return $this->getConnection()->fetchAll($select);
132+
133+
$productTable = $this->getTable('catalog_product_entity');
134+
$selectProducts = $this->getConnection()->select()->from(['p' => $productTable], [])
135+
->where('entity_id IN (?)', $productIds)
136+
->columns(
137+
[
138+
'product_id' => 'entity_id',
139+
'type_id' => 'type_id'
140+
]
141+
);
142+
$this->getConnection()->query($select);
143+
144+
return $this->getConnection()->fetchAll($selectProducts);
135145
}
136146

137147
/**

0 commit comments

Comments
 (0)