/**
  * @param AMQPMessage $msg The message
  * @return mixed false to reject and requeue, any other value to aknowledge
  */
 public function execute(AMQPMessage $msg)
 {
     $msgBody = json_decode($msg->body);
     $erpOrderId = $msgBody->payload->erpOrderId;
     $shopifyOrderId = $msgBody->payload->shopifyOrderId;
     $storeId = $msgBody->payload->storeId;
     try {
         $store = $this->store->getStore($storeId);
         $order = $this->erpClient->getOrder($store, $erpOrderId);
         $erpShipment = $this->erpClient->getShipment($store, $order);
         $shopifyOrder = $this->shopifyApiClient->getOrder($store, $shopifyOrderId);
         $isShipmentFulfilled = $this->erpShipmentService->isShipmentFulfilled($erpShipment, $shopifyOrder);
         $this->erpShipmentService->setFulfilledItems($erpShipment, $shopifyOrder);
         //Send the order off to be updated
         $this->shopifyApiClient->updateOrCreateFulfillments($store, $shopifyOrder, $erpShipment);
         if ($isShipmentFulfilled) {
             //Send the order off for completion
             $this->shopifyApiClient->completeOrder($store, $shopifyOrder);
         }
     } catch (ErpOrderNotFound $e) {
         return false;
     } catch (ErpShipmentNotFound $e) {
         return false;
     } catch (\Exception $e) {
         return false;
     }
 }
예제 #2
0
 /**
  * @param AMQPMessage $msg The message
  * @return mixed false to reject and requeue, any other value to aknowledge
  */
 public function execute(AMQPMessage $msg)
 {
     $msgBody = json_decode($msg->body);
     $catalogId = $msgBody->payload->catalog;
     $storeId = $msgBody->payload->storeId;
     $store = $this->store->getStore($storeId);
     $catalog = $this->store->getCatalog($catalogId, $store);
     $productCatalog = $this->erpClient->getProducts($store, $catalog[0], true);
     $this->productCatalog->collectProductsFromShopifyAndImport($catalog[0], $store, $productCatalog);
     $this->productCatalog->createProductsOrUpdate($productCatalog, $store);
     $this->productCatalog->addProductsToCollection($productCatalog, $store);
     $this->productCatalog->checkHandlingFeeProductAndCreateIt($store);
 }