public function testUpdateQuoteItemsWithConfiguredOption() { $qty = 100000000; $items = [1 => ['qty' => 10, 'configured' => true, 'action' => false]]; $itemMock = $this->getMock('Magento\\Quote\\Model\\Quote\\Item', [], [], '', false); $itemMock->expects($this->once())->method('getQty')->will($this->returnValue($qty)); $quoteMock = $this->getMock('Magento\\Quote\\Model\\Quote', [], [], '', false); $quoteMock->expects($this->once())->method('updateItem')->will($this->returnValue($itemMock)); $this->sessionQuoteMock->expects($this->any())->method('getQuote')->will($this->returnValue($quoteMock)); $expectedInfo = $items[1]; $expectedInfo['qty'] = $qty; $this->itemUpdater->expects($this->once())->method('update')->with($this->equalTo($itemMock), $this->equalTo($expectedInfo)); $this->adminOrderCreate->setRecollect(false); $this->adminOrderCreate->updateQuoteItems($items); }
/** * Update quantity of order quote items * * @param array $items * @return $this * @throws \Exception|\Magento\Framework\Exception\LocalizedException */ public function updateQuoteItems($items) { if (!is_array($items)) { return $this; } try { foreach ($items as $itemId => $info) { if (!empty($info['configured'])) { $item = $this->getQuote()->updateItem($itemId, $this->objectFactory->create($info)); $info['qty'] = (double) $item->getQty(); } else { $item = $this->getQuote()->getItemById($itemId); if (!$item) { continue; } $info['qty'] = (double) $info['qty']; } $this->quoteItemUpdater->update($item, $info); if ($item && !empty($info['action'])) { $this->moveQuoteItem($item, $info['action'], $item->getQty()); } } } catch (\Magento\Framework\Exception\LocalizedException $e) { $this->recollectCart(); throw $e; } catch (\Exception $e) { $this->_logger->critical($e); } $this->recollectCart(); return $this; }