Skip to content

Commit

Permalink
Trying to get data from non existent products
Browse files Browse the repository at this point in the history
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
  • Loading branch information
angelo983 authored Dec 4, 2017
1 parent 4067591 commit 5fc8d61
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
Expand Down

0 comments on commit 5fc8d61

Please sign in to comment.