Exemplo n.º 1
0
 /**
  * @param StoreEntity $store
  * @param ErpOrderEntity $erpOrder
  * @return ErpShipmentEntity
  * @throws ErpShipmentNotFound
  */
 public function getShipment(StoreEntity $store, ErpOrderEntity $erpOrder)
 {
     $request = $this->client->createRequest('GET', sprintf('%s/shipments/?order=%s', $store->getErpUrl(), $erpOrder->getOrderId()), ['auth' => [$store->getErpUsername(), $store->getErpPassword()]]);
     try {
         $response = $this->sendRequest($request)->xml();
     } catch (\Exception $e) {
         throw new ErpShipmentNotFound(sprintf('Not shipment can be found with the order id %s', $erpOrder->getOrderId()));
     }
     return ErpShipmentEntity::createFromShipmentXMLObject($response);
 }
 /**
  * @param StoreEntity $store
  * @param ErpOrderEntity $order
  */
 public function updateOrderWithErpData(StoreEntity $store, ErpOrderEntity $order)
 {
     $this->setSettings($store);
     $erpData = new \stdClass();
     $erpData->key = 'erp-id';
     $erpData->value = $order->getOrderId();
     $erpData->value_type = 'string';
     $erpData->namespace = 'global';
     $this->client->updateOrder(['id' => $order->getShopifyOrderId(), 'order' => ['id' => $order->getShopifyOrderId(), 'metafields' => [$erpData]]]);
 }