/** * Adds stock item qty to $items (creates new entry or increments existing one) * * @param QuoteItem $quoteItem * @param array &$items * @return void */ protected function _addItemToQtyArray(QuoteItem $quoteItem, &$items) { $productId = $quoteItem->getProductId(); if (!$productId) { return; } if (isset($items[$productId])) { $items[$productId] += $quoteItem->getTotalQty(); } else { $items[$productId] = $quoteItem->getTotalQty(); } }
/** * Adds stock item qty to $items (creates new entry or increments existing one) * $items is array with following structure: * array( * $productId => array( * 'qty' => $qty, * 'item' => $stockItems|null * ) * ) * * @param QuoteItem $quoteItem * @param array &$items * @return void */ protected function _addItemToQtyArray(QuoteItem $quoteItem, &$items) { $productId = $quoteItem->getProductId(); if (!$productId) { return; } if (isset($items[$productId])) { $items[$productId] += $quoteItem->getTotalQty(); } else { $stockItem = null; if ($quoteItem->getProduct()) { /** @var Item $stockItem */ $stockItem = $this->stockRegistry->getStockItem($quoteItem->getProduct()->getId(), $quoteItem->getStore()->getWebsiteId()); } $items[$productId] = $quoteItem->getTotalQty(); } }