From 8310be3d7e33f7532dc4765c1a19a175f891eb00 Mon Sep 17 00:00:00 2001 From: Sean Templeton Date: Mon, 9 Jul 2018 22:55:49 -0500 Subject: [PATCH] Prevent running SQL query on every item in the database when the quote is empty --- .../Quote/Model/ResourceModel/Quote/Item/Collection.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/code/Magento/Quote/Model/ResourceModel/Quote/Item/Collection.php b/app/code/Magento/Quote/Model/ResourceModel/Quote/Item/Collection.php index 0487d7e46eb26..1938d7bd2780e 100644 --- a/app/code/Magento/Quote/Model/ResourceModel/Quote/Item/Collection.php +++ b/app/code/Magento/Quote/Model/ResourceModel/Quote/Item/Collection.php @@ -309,6 +309,10 @@ private function addTierPriceData(ProductCollection $productCollection) */ private function removeItemsWithAbsentProducts() { + if (count($this->_productIds) === 0) { + return; + } + $productCollection = $this->_productCollectionFactory->create()->addIdFilter($this->_productIds); $existingProductsIds = $productCollection->getAllIds(); $absentProductsIds = array_diff($this->_productIds, $existingProductsIds);