From 5fc8d61ddf9cfd71e67bb6cd415b4b0dfaf2808c Mon Sep 17 00:00:00 2001 From: angelo983 Date: Mon, 4 Dec 2017 16:44:42 +0100 Subject: [PATCH] Trying to get data from non existent products As requested in #12321 When calling Products in Cart report, it called data of deleted products resulting in exception trying to access $productData[$item->getProductId()] ### Preconditions 1. Magento 2.1.10 ### Steps to reproduce 1. Delete a product recently sold 1. Open Reports > Marketing > Products in Cart ### Expected result 1. List of products ### Actual result 1. Blank list --- .../Reports/Model/ResourceModel/Quote/Item/Collection.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Reports/Model/ResourceModel/Quote/Item/Collection.php b/app/code/Magento/Reports/Model/ResourceModel/Quote/Item/Collection.php index 6e891c481aebe..e9dbfdae7a9a5 100644 --- a/app/code/Magento/Reports/Model/ResourceModel/Quote/Item/Collection.php +++ b/app/code/Magento/Reports/Model/ResourceModel/Quote/Item/Collection.php @@ -220,8 +220,10 @@ protected function _afterLoad() $orderData = $this->getOrdersData($productIds); foreach ($items as $item) { $item->setId($item->getProductId()); - $item->setPrice($productData[$item->getProductId()]['price'] * $item->getBaseToGlobalRate()); - $item->setName($productData[$item->getProductId()]['name']); + if (isset($productData[$item->getProductId()])) { + $item->setPrice($productData[$item->getProductId()]['price'] * $item->getBaseToGlobalRate()); + $item->setName($productData[$item->getProductId()]['name']); + } $item->setOrders(0); if (isset($orderData[$item->getProductId()])) { $item->setOrders($orderData[$item->getProductId()]['orders']);