Skip to content

Commit 5fc8d61

Browse files
authored
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 <!--- Provide a more detailed information of environment you use --> <!--- Magento version, tag, HEAD, etc., PHP & MySQL version, etc.. --> 1. Magento 2.1.10 ### Steps to reproduce <!--- Provide a set of unambiguous steps to reproduce this bug include code, if relevant --> 1. Delete a product recently sold 1. Open Reports > Marketing > Products in Cart ### Expected result <!--- Tell us what should happen --> 1. List of products ### Actual result <!--- Tell us what happens instead --> 1. Blank list
1 parent 4067591 commit 5fc8d61

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,10 @@ protected function _afterLoad()
220220
$orderData = $this->getOrdersData($productIds);
221221
foreach ($items as $item) {
222222
$item->setId($item->getProductId());
223-
$item->setPrice($productData[$item->getProductId()]['price'] * $item->getBaseToGlobalRate());
224-
$item->setName($productData[$item->getProductId()]['name']);
223+
if (isset($productData[$item->getProductId()])) {
224+
$item->setPrice($productData[$item->getProductId()]['price'] * $item->getBaseToGlobalRate());
225+
$item->setName($productData[$item->getProductId()]['name']);
226+
}
225227
$item->setOrders(0);
226228
if (isset($orderData[$item->getProductId()])) {
227229
$item->setOrders($orderData[$item->getProductId()]['orders']);

0 commit comments

Comments
 (0)