Created
May 31, 2016 16:05
-
-
Save yuklia/c9be29a9d7796b4130ebf18a7d4f53c0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function addOrderItem($orderItem, $qtyFlag = null) | |
{ | |
/* @var $orderItem \Magento\Sales\Model\Order\Item */ | |
if ($orderItem->getParentItem() === null) { | |
$storeId = $this->_storeManager->getStore()->getId(); | |
try { | |
$product = $this->productRepository->getById($orderItem->getProductId(), false, $storeId); | |
} catch (NoSuchEntityException $e) { | |
return $this; | |
} | |
$info = $orderItem->getProductOptionByCode('info_buyRequest'); | |
$info = new \Magento\Framework\DataObject($info); | |
if ($qtyFlag === null) { | |
$info->setQty($orderItem->getQtyOrdered()); | |
} else { | |
$info->setQty(1); | |
} | |
$this->addProduct($product, $info); | |
} | |
return $this; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment