Esempio n. 1
0
 /**
  * Convert Magento SaleOrderItem to service item.
  *
  * @param \Magento\Sales\Api\Data\OrderItemInterface $item
  * @param int $stockId
  * @return \Praxigento\Pv\Service\Sale\Data\Item
  */
 public function getServiceItemForMageItem(\Magento\Sales\Api\Data\OrderItemInterface $item, $stockId = null)
 {
     $result = $this->_manObj->create(\Praxigento\Pv\Service\Sale\Data\Item::class);
     $prodId = $item->getProductId();
     $itemId = $item->getItemId();
     /* qty of the product can be changed in invoice but we use ordered only */
     $qty = $item->getQtyOrdered();
     /* create data item for service */
     $result->setItemId($itemId);
     $result->setProductId($prodId);
     $result->setQuantity($qty);
     $result->setStockId($stockId);
     return $result;
 }
 /**
  * Retrieve order item's buy request
  *
  * @param OrderItemInterface $entity
  * @return DataObject
  */
 protected function getBuyRequest(OrderItemInterface $entity)
 {
     $request = $this->objectFactory->create(['qty' => $entity->getQtyOrdered()]);
     $productType = $entity->getProductType();
     if (isset($this->processorPool[$productType]) && !$entity->getParentItemId()) {
         $productOption = $entity->getProductOption();
         if ($productOption) {
             $requestUpdate = $this->processorPool[$productType]->convertToBuyRequest($productOption);
             $request->addData($requestUpdate->getData());
         }
     }
     if (isset($this->processorPool['custom_options']) && !$entity->getParentItemId()) {
         $productOption = $entity->getProductOption();
         if ($productOption) {
             $requestUpdate = $this->processorPool['custom_options']->convertToBuyRequest($productOption);
             $request->addData($requestUpdate->getData());
         }
     }
     return $request;
 }