Skip to content

Commit 8310be3

Browse files
LordZardeckmage2pratik
authored andcommitted
Prevent running SQL query on every item in the database when the quote is empty
1 parent 1d469f8 commit 8310be3

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

app/code/Magento/Quote/Model/ResourceModel/Quote/Item/Collection.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,10 @@ private function addTierPriceData(ProductCollection $productCollection)
309309
*/
310310
private function removeItemsWithAbsentProducts()
311311
{
312+
if (count($this->_productIds) === 0) {
313+
return;
314+
}
315+
312316
$productCollection = $this->_productCollectionFactory->create()->addIdFilter($this->_productIds);
313317
$existingProductsIds = $productCollection->getAllIds();
314318
$absentProductsIds = array_diff($this->_productIds, $existingProductsIds);

0 commit comments

Comments
 (0)