/** * @param Shipment $dataObject * @return \Magento\Sales\Model\Order\Shipment * @throws \Exception */ public function getModel(Shipment $dataObject) { $this->shipmentLoader->setOrderId($dataObject->getOrderId()); $this->shipmentLoader->setShipmentId($dataObject->getEntityId()); $items = []; foreach ($dataObject->getItems() as $item) { $items[$item->getOrderItemId()] = $item->getQty(); } $shipmentItems = ['items' => $items]; $this->shipmentLoader->setShipment($shipmentItems); $this->shipmentLoader->setTracking($dataObject->getTracks()); return $this->shipmentLoader->load(); }