Skip to content

Commit

Permalink
Update fetching quote item by id
Browse files Browse the repository at this point in the history
Fixes #9445

Fix's issue when quote item without id is added to collection
  • Loading branch information
mladenilic committed Jun 26, 2017
1 parent d03bc98 commit 1fb3a97
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions app/code/Magento/Quote/Model/Quote.php
Original file line number Diff line number Diff line change
Expand Up @@ -1444,11 +1444,17 @@ public function hasProductId($productId)
* Retrieve item model object by item identifier
*
* @param int $itemId
* @return \Magento\Quote\Model\Quote\Item
* @return \Magento\Quote\Model\Quote\Item|false
*/
public function getItemById($itemId)
{
return $this->getItemsCollection()->getItemById($itemId);
foreach ($this->getItemsCollection() as $item) {
if ($item->getId() == $itemId) {
return $item;
}
}

return false;

This comment has been minimized.

Copy link
@tshabatyn

tshabatyn Aug 16, 2019

null should be returned

This comment has been minimized.

Copy link
@mladenilic

mladenilic Aug 16, 2019

Author Contributor

agree

}

/**
Expand Down

0 comments on commit 1fb3a97

Please sign in to comment.