Skip to content

Commit 9ab5045

Browse files
ENGCOM-2254: Prevent running SQL query on every item in the database when the quote is empty #16675
- Merge Pull Request #16675 from LordZardeck/magento2:empty-cart-performance - Merged commits: 1. eb4f650
2 parents 856def3 + eb4f650 commit 9ab5045

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
@@ -323,6 +323,10 @@ private function addTierPriceData(ProductCollection $productCollection)
323323
*/
324324
private function removeItemsWithAbsentProducts()
325325
{
326+
if (count($this->_productIds) === 0) {
327+
return;
328+
}
329+
326330
$productCollection = $this->_productCollectionFactory->create()->addIdFilter($this->_productIds);
327331
$existingProductsIds = $productCollection->getAllIds();
328332
$absentProductsIds = array_diff($this->_productIds, $existingProductsIds);

0 commit comments

Comments
 (0)