/** * Process relations for CreditMemo * * @param \Magento\Sales\Model\AbstractModel $object * @throws \Exception * @return void */ public function processRelation(\Magento\Sales\Model\AbstractModel $object) { /** @var \Magento\Sales\Model\Order\Creditmemo $object */ if (null !== $object->getItems()) { foreach ($object->getItems() as $item) { $item->setParentId($object->getId()); $this->creditmemoItemResource->save($item); } } if (null !== $object->getComments()) { foreach ($object->getComments() as $comment) { $this->creditmemoCommentResource->save($comment); } } }
/** * Process relations for Shipment * * @param \Magento\Sales\Model\AbstractModel $object * @return void * @throws \Exception */ public function processRelation(\Magento\Sales\Model\AbstractModel $object) { /** @var $object \Magento\Sales\Model\Order\Invoice */ if (null !== $object->getItems()) { foreach ($object->getItems() as $item) { /** @var \Magento\Sales\Model\Order\Invoice\Item */ $item->setParentId($object->getId()); $item->setOrderItem($item->getOrderItem()); $this->invoiceItemResource->save($item); } } if (null !== $object->getComments()) { foreach ($object->getComments() as $comment) { /** @var \Magento\Sales\Model\Order\Invoice\Comment */ $this->invoiceCommentResource->save($comment); } } }