当前位置: 首页>>代码示例>>PHP>>正文


PHP ShipmentLoader::setOrderId方法代码示例

本文整理汇总了PHP中Magento\Shipping\Controller\Adminhtml\Order\ShipmentLoader::setOrderId方法的典型用法代码示例。如果您正苦于以下问题:PHP ShipmentLoader::setOrderId方法的具体用法?PHP ShipmentLoader::setOrderId怎么用?PHP ShipmentLoader::setOrderId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Magento\Shipping\Controller\Adminhtml\Order\ShipmentLoader的用法示例。


在下文中一共展示了ShipmentLoader::setOrderId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: executeInternal

    /**
     * Create pdf document with information about packages
     *
     * @return ResponseInterface|void
     */
    public function executeInternal()
    {
        $this->shipmentLoader->setOrderId($this->getRequest()->getParam('order_id'));
        $this->shipmentLoader->setShipmentId($this->getRequest()->getParam('shipment_id'));
        $this->shipmentLoader->setShipment($this->getRequest()->getParam('shipment'));
        $this->shipmentLoader->setTracking($this->getRequest()->getParam('tracking'));
        $shipment = $this->shipmentLoader->load();

        if ($shipment) {
            /** @var \Zend_Pdf $pdf */
            $pdf = $this->_objectManager->create('Magento\Shipping\Model\Order\Pdf\Packaging')->getPdf($shipment);
            return $this->_fileFactory->create(
                'packingslip' . $this->_objectManager->get(
                    'Magento\Framework\Stdlib\DateTime\DateTime'
                )->date(
                    'Y-m-d_H-i-s'
                ) . '.pdf',
                $pdf->render(),
                DirectoryList::VAR_DIR,
                'application/pdf'
            );
        } else {
            $this->_forward('noroute');
        }
    }
开发者ID:nblair,项目名称:magescotch,代码行数:30,代码来源:PrintPackage.php

示例2: execute

 /**
  * Add comment to shipment history
  *
  * @return void
  */
 public function execute()
 {
     try {
         $this->getRequest()->setParam('shipment_id', $this->getRequest()->getParam('id'));
         $data = $this->getRequest()->getPost('comment');
         if (empty($data['comment'])) {
             throw new \Magento\Framework\Exception\LocalizedException(__("The comment text field cannot be empty."));
         }
         $this->shipmentLoader->setOrderId($this->getRequest()->getParam('order_id'));
         $this->shipmentLoader->setShipmentId($this->getRequest()->getParam('shipment_id'));
         $this->shipmentLoader->setShipment($this->getRequest()->getParam('shipment'));
         $this->shipmentLoader->setTracking($this->getRequest()->getParam('tracking'));
         $shipment = $this->shipmentLoader->load();
         $shipment->addComment($data['comment'], isset($data['is_customer_notified']), isset($data['is_visible_on_front']));
         $this->shipmentCommentSender->send($shipment, !empty($data['is_customer_notified']), $data['comment']);
         $shipment->save();
         $resultLayout = $this->resultLayoutFactory->create();
         $resultLayout->addDefaultHandle();
         $response = $resultLayout->getLayout()->getBlock('shipment_comments')->toHtml();
     } catch (\Magento\Framework\Exception\LocalizedException $e) {
         $response = ['error' => true, 'message' => $e->getMessage()];
     } catch (\Exception $e) {
         $response = ['error' => true, 'message' => __('Cannot add new comment.')];
     }
     if (is_array($response)) {
         $response = $this->_objectManager->get('Magento\\Framework\\Json\\Helper\\Data')->jsonEncode($response);
         $this->getResponse()->representJson($response);
     } else {
         $this->getResponse()->setBody($response);
     }
 }
开发者ID:opexsw,项目名称:magento2,代码行数:36,代码来源:AddComment.php

示例3: execute

 /**
  * Print label for one specific shipment
  *
  * @return ResponseInterface|void
  */
 public function execute()
 {
     try {
         $this->shipmentLoader->setOrderId($this->getRequest()->getParam('order_id'));
         $this->shipmentLoader->setShipmentId($this->getRequest()->getParam('shipment_id'));
         $this->shipmentLoader->setShipment($this->getRequest()->getParam('shipment'));
         $this->shipmentLoader->setTracking($this->getRequest()->getParam('tracking'));
         $shipment = $this->shipmentLoader->load();
         $labelContent = $shipment->getShippingLabel();
         if ($labelContent) {
             $pdfContent = null;
             if (stripos($labelContent, '%PDF-') !== false) {
                 $pdfContent = $labelContent;
             } else {
                 $pdf = new \Zend_Pdf();
                 $page = $this->labelGenerator->createPdfPageFromImageString($labelContent);
                 if (!$page) {
                     $this->messageManager->addError(__('We don\'t recognize or support the file extension in this shipment: %1.', $shipment->getIncrementId()));
                 }
                 $pdf->pages[] = $page;
                 $pdfContent = $pdf->render();
             }
             return $this->_fileFactory->create('ShippingLabel(' . $shipment->getIncrementId() . ').pdf', $pdfContent, DirectoryList::VAR_DIR, 'application/pdf');
         }
     } catch (\Magento\Framework\Exception\LocalizedException $e) {
         $this->messageManager->addError($e->getMessage());
     } catch (\Exception $e) {
         $this->_objectManager->get('Psr\\Log\\LoggerInterface')->critical($e);
         $this->messageManager->addError(__('An error occurred while creating shipping label.'));
     }
     $this->_redirect('adminhtml/order_shipment/view', ['shipment_id' => $this->getRequest()->getParam('shipment_id')]);
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:37,代码来源:PrintLabel.php

示例4: execute

 /**
  * Remove tracking number from shipment
  *
  * @return void
  */
 public function execute()
 {
     $trackId = $this->getRequest()->getParam('track_id');
     /** @var \Magento\Sales\Model\Order\Shipment\Track $track */
     $track = $this->_objectManager->create('Magento\\Sales\\Model\\Order\\Shipment\\Track')->load($trackId);
     if ($track->getId()) {
         try {
             $this->shipmentLoader->setOrderId($this->getRequest()->getParam('order_id'));
             $this->shipmentLoader->setShipmentId($this->getRequest()->getParam('shipment_id'));
             $this->shipmentLoader->setShipment($this->getRequest()->getParam('shipment'));
             $this->shipmentLoader->setTracking($this->getRequest()->getParam('tracking'));
             $shipment = $this->shipmentLoader->load();
             if ($shipment) {
                 $track->delete();
                 $this->_view->loadLayout();
                 $this->_view->getPage()->getConfig()->getTitle()->prepend(__('Shipments'));
                 $response = $this->_view->getLayout()->getBlock('shipment_tracking')->toHtml();
             } else {
                 $response = ['error' => true, 'message' => __('We can\'t initialize shipment for delete tracking number.')];
             }
         } catch (\Exception $e) {
             $response = ['error' => true, 'message' => __('We can\'t delete tracking number.')];
         }
     } else {
         $response = ['error' => true, 'message' => __('We can\'t load track with retrieving identifier right now.')];
     }
     if (is_array($response)) {
         $response = $this->_objectManager->get('Magento\\Framework\\Json\\Helper\\Data')->jsonEncode($response);
         $this->getResponse()->representJson($response);
     } else {
         $this->getResponse()->setBody($response);
     }
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:38,代码来源:RemoveTrack.php

示例5: execute

 /**
  * Return grid with shipping items for Ajax request
  *
  * @return ResponseInterface
  */
 public function execute()
 {
     $this->shipmentLoader->setOrderId($this->getRequest()->getParam('order_id'));
     $this->shipmentLoader->setShipmentId($this->getRequest()->getParam('shipment_id'));
     $this->shipmentLoader->setShipment($this->getRequest()->getParam('shipment'));
     $this->shipmentLoader->setTracking($this->getRequest()->getParam('tracking'));
     $this->shipmentLoader->load();
     return $this->getResponse()->setBody($this->_view->getLayout()->createBlock('Magento\\Shipping\\Block\\Adminhtml\\Order\\Packaging\\Grid')->setIndex($this->getRequest()->getParam('index'))->toHtml());
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:14,代码来源:GetShippingItemsGrid.php

示例6: getModel

 /**
  * @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();
 }
开发者ID:aiesh,项目名称:magento2,代码行数:18,代码来源:ShipmentConverter.php

示例7: executeInternal

    /**
     * Add new tracking number action
     *
     * @return void
     * @throws \Magento\Framework\Exception\LocalizedException
     */
    public function executeInternal()
    {
        try {
            $carrier = $this->getRequest()->getPost('carrier');
            $number = $this->getRequest()->getPost('number');
            $title = $this->getRequest()->getPost('title');
            if (empty($carrier)) {
                throw new \Magento\Framework\Exception\LocalizedException(__('Please specify a carrier.'));
            }
            if (empty($number)) {
                throw new \Magento\Framework\Exception\LocalizedException(__('Please enter a tracking number.'));
            }
            $this->shipmentLoader->setOrderId($this->getRequest()->getParam('order_id'));
            $this->shipmentLoader->setShipmentId($this->getRequest()->getParam('shipment_id'));
            $this->shipmentLoader->setShipment($this->getRequest()->getParam('shipment'));
            $this->shipmentLoader->setTracking($this->getRequest()->getParam('tracking'));
            $shipment = $this->shipmentLoader->load();
            if ($shipment) {
                $track = $this->_objectManager->create(
                    'Magento\Sales\Model\Order\Shipment\Track'
                )->setNumber(
                    $number
                )->setCarrierCode(
                    $carrier
                )->setTitle(
                    $title
                );
                $shipment->addTrack($track)->save();

                $this->_view->loadLayout();
                $this->_view->getPage()->getConfig()->getTitle()->prepend(__('Shipments'));
                $response = $this->_view->getLayout()->getBlock('shipment_tracking')->toHtml();
            } else {
                $response = [
                    'error' => true,
                    'message' => __('We can\'t initialize shipment for adding tracking number.'),
                ];
            }
        } catch (\Magento\Framework\Exception\LocalizedException $e) {
            $response = ['error' => true, 'message' => $e->getMessage()];
        } catch (\Exception $e) {
            $response = ['error' => true, 'message' => __('Cannot add tracking number.')];
        }
        if (is_array($response)) {
            $response = $this->_objectManager->get('Magento\Framework\Json\Helper\Data')->jsonEncode($response);
            $this->getResponse()->representJson($response);
        } else {
            $this->getResponse()->setBody($response);
        }
    }
开发者ID:nblair,项目名称:magescotch,代码行数:56,代码来源:AddTrack.php

示例8: execute

 /**
  * Send email with shipment data to customer
  *
  * @return \Magento\Backend\Model\View\Result\Redirect
  */
 public function execute()
 {
     $this->shipmentLoader->setOrderId($this->getRequest()->getParam('order_id'));
     $this->shipmentLoader->setShipmentId($this->getRequest()->getParam('shipment_id'));
     $this->shipmentLoader->setShipment($this->getRequest()->getParam('shipment'));
     $this->shipmentLoader->setTracking($this->getRequest()->getParam('tracking'));
     $shipment = $this->shipmentLoader->load();
     if ($shipment) {
         $this->_objectManager->create('Magento\\Shipping\\Model\\ShipmentNotifier')->notify($shipment);
         $shipment->save();
         $this->messageManager->addSuccess(__('You sent the shipment.'));
     }
     return $this->getDefaultResult();
 }
开发者ID:opexsw,项目名称:magento2,代码行数:19,代码来源:Email.php

示例9: execute

 /**
  * Shipment information page
  *
  * @return void
  */
 public function execute()
 {
     $this->_title->add(__('Shipments'));
     $this->shipmentLoader->setOrderId($this->getRequest()->getParam('order_id'));
     $this->shipmentLoader->setShipmentId($this->getRequest()->getParam('shipment_id'));
     $this->shipmentLoader->setShipment($this->getRequest()->getParam('shipment'));
     $this->shipmentLoader->setTracking($this->getRequest()->getParam('tracking'));
     $shipment = $this->shipmentLoader->load();
     if ($shipment) {
         $this->_title->add("#" . $shipment->getIncrementId());
         $this->_view->loadLayout();
         $this->_view->getLayout()->getBlock('sales_shipment_view')->updateBackButtonUrl($this->getRequest()->getParam('come_from'));
         $this->_setActiveMenu('Magento_Sales::sales_order');
         $this->_view->renderLayout();
     } else {
         $this->_forward('noroute');
     }
 }
开发者ID:aiesh,项目名称:magento2,代码行数:23,代码来源:View.php

示例10: shipmentTrackingSave

 public function shipmentTrackingSave(\Praxigento\Odoo\Api\Data\SaleOrder\Shipment\Tracking $data)
 {
     $result = false;
     /* replicate all data in one transaction */
     $def = $this->_manTrans->begin();
     try {
         $orderIdMage = $data->getSaleOrderIdMage();
         $trackNumber = $data->getData('shipment/trackingInfo/trackingNumber');
         $shippingMethodCode = $data->getData('shipment/trackingInfo/shippingCode');
         $this->_shipmentLoader->setOrderId($orderIdMage);
         /** @var \Magento\Sales\Model\Order\Shipment $shipment */
         $shipment = $this->_shipmentLoader->load();
         if ($shipment) {
             $carrierCode = $this->_manBusCodes->getMagCodeForCarrier($shippingMethodCode);
             $title = $this->_manBusCodes->getTitleForCarrier($shippingMethodCode);
             $track = $this->_manObj->create(\Magento\Sales\Model\Order\Shipment\Track::class);
             $track->setNumber($trackNumber);
             $track->setCarrierCode($carrierCode);
             $track->setTitle($title);
             $shipment->addTrack($track);
             $shipment->register();
             $shipment->save();
             $order = $shipment->getOrder();
             $invoice = $this->_manInvoice->prepareInvoice($order);
             $invoice->register();
             $invoice->save();
             $order->save();
             $this->_manTrans->commit($def);
             $result = true;
         }
     } catch (\Exception $e) {
         $msg = 'Product replication from Odoo is failed. Error: ' . $e->getMessage();
         $this->_logger->emergency($msg);
         $traceStr = $e->getTraceAsString();
         $this->_logger->emergency($traceStr);
         throw $e;
     } finally {
         // transaction will be rolled back if commit is not done (otherwise - do nothing)
         $this->_manTrans->end($def);
     }
     return $result;
 }
开发者ID:praxigento,项目名称:mobi_mod_mage2_odoo,代码行数:42,代码来源:SaleOrderReplicator.php

示例11: execute

 /**
  * Shipment information page
  *
  * @return void
  */
 public function execute()
 {
     $this->shipmentLoader->setOrderId($this->getRequest()->getParam('order_id'));
     $this->shipmentLoader->setShipmentId($this->getRequest()->getParam('shipment_id'));
     $this->shipmentLoader->setShipment($this->getRequest()->getParam('shipment'));
     $this->shipmentLoader->setTracking($this->getRequest()->getParam('tracking'));
     $shipment = $this->shipmentLoader->load();
     if ($shipment) {
         $resultPage = $this->resultPageFactory->create();
         $resultPage->getLayout()->getBlock('sales_shipment_view')->updateBackButtonUrl($this->getRequest()->getParam('come_from'));
         $resultPage->setActiveMenu('Magento_Sales::sales_shipment');
         $resultPage->getConfig()->getTitle()->prepend(__('Shipments'));
         $resultPage->getConfig()->getTitle()->prepend("#" . $shipment->getIncrementId());
         return $resultPage;
     } else {
         $resultForward = $this->resultForwardFactory->create();
         $resultForward->forward('noroute');
         return $resultForward;
     }
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:25,代码来源:View.php

示例12: execute

 /**
  * Send email with shipment data to customer
  *
  * @return void
  */
 public function execute()
 {
     try {
         $this->shipmentLoader->setOrderId($this->getRequest()->getParam('order_id'));
         $this->shipmentLoader->setShipmentId($this->getRequest()->getParam('shipment_id'));
         $this->shipmentLoader->setShipment($this->getRequest()->getParam('shipment'));
         $this->shipmentLoader->setTracking($this->getRequest()->getParam('tracking'));
         $shipment = $this->shipmentLoader->load();
         if ($shipment) {
             $this->_objectManager->create('Magento\\Shipping\\Model\\ShipmentNotifier')->notify($shipment);
             $shipment->save();
             $this->messageManager->addSuccess(__('You sent the shipment.'));
         }
     } catch (\Magento\Framework\Exception\LocalizedException $e) {
         $this->messageManager->addError($e->getMessage());
     } catch (\Exception $e) {
         $this->messageManager->addError(__('Cannot send shipment information.'));
     }
     $this->_redirect('*/*/view', ['shipment_id' => $this->getRequest()->getParam('shipment_id')]);
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:25,代码来源:Email.php

示例13: execute

 /**
  * Shipment create page
  *
  * @return void
  */
 public function execute()
 {
     $this->shipmentLoader->setOrderId($this->getRequest()->getParam('order_id'));
     $this->shipmentLoader->setShipmentId($this->getRequest()->getParam('shipment_id'));
     $this->shipmentLoader->setShipment($this->getRequest()->getParam('shipment'));
     $this->shipmentLoader->setTracking($this->getRequest()->getParam('tracking'));
     $shipment = $this->shipmentLoader->load();
     if ($shipment) {
         $comment = $this->_objectManager->get('Magento\\Backend\\Model\\Session')->getCommentText(true);
         if ($comment) {
             $shipment->setCommentText($comment);
         }
         $this->_view->loadLayout();
         $this->_setActiveMenu('Magento_Sales::sales_order');
         $this->_view->getPage()->getConfig()->getTitle()->prepend(__('Shipments'));
         $this->_view->getPage()->getConfig()->getTitle()->prepend(__('New Shipment'));
         $this->_view->renderLayout();
     } else {
         $this->_redirect('*/order/view', ['order_id' => $this->getRequest()->getParam('order_id')]);
     }
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:26,代码来源:NewAction.php

示例14: execute

 /**
  * Create shipping label action for specific shipment
  *
  * @return void
  */
 public function execute()
 {
     $response = new \Magento\Framework\DataObject();
     try {
         $this->shipmentLoader->setOrderId($this->getRequest()->getParam('order_id'));
         $this->shipmentLoader->setShipmentId($this->getRequest()->getParam('shipment_id'));
         $this->shipmentLoader->setShipment($this->getRequest()->getParam('shipment'));
         $this->shipmentLoader->setTracking($this->getRequest()->getParam('tracking'));
         $shipment = $this->shipmentLoader->load();
         $this->labelGenerator->create($shipment, $this->_request);
         $shipment->save();
         $this->messageManager->addSuccess(__('You created the shipping label.'));
         $response->setOk(true);
     } catch (\Magento\Framework\Exception\LocalizedException $e) {
         $response->setError(true);
         $response->setMessage($e->getMessage());
     } catch (\Exception $e) {
         $this->_objectManager->get('Psr\\Log\\LoggerInterface')->critical($e);
         $response->setError(true);
         $response->setMessage(__('An error occurred while creating shipping label.'));
     }
     $this->getResponse()->representJson($response->toJson());
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:28,代码来源:CreateLabel.php

示例15: execute

 /**
  * Save shipment
  * We can save only new shipment. Existing shipments are not editable
  *
  * @return void
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 public function execute()
 {
     /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
     $resultRedirect = $this->resultRedirectFactory->create();
     $formKeyIsValid = $this->_formKeyValidator->validate($this->getRequest());
     $isPost = $this->getRequest()->isPost();
     if (!$formKeyIsValid || !$isPost) {
         $this->messageManager->addError(__('We can\'t save the shipment right now.'));
         return $resultRedirect->setPath('sales/order/index');
     }
     $data = $this->getRequest()->getParam('shipment');
     if (!empty($data['comment_text'])) {
         $this->_objectManager->get('Magento\\Backend\\Model\\Session')->setCommentText($data['comment_text']);
     }
     try {
         $this->shipmentLoader->setOrderId($this->getRequest()->getParam('order_id'));
         $this->shipmentLoader->setShipmentId($this->getRequest()->getParam('shipment_id'));
         $this->shipmentLoader->setShipment($data);
         $this->shipmentLoader->setTracking($this->getRequest()->getParam('tracking'));
         $shipment = $this->shipmentLoader->load();
         if (!$shipment) {
             $this->_forward('noroute');
             return;
         }
         if (!empty($data['comment_text'])) {
             $shipment->addComment($data['comment_text'], isset($data['comment_customer_notify']), isset($data['is_visible_on_front']));
             $shipment->setCustomerNote($data['comment_text']);
             $shipment->setCustomerNoteNotify(isset($data['comment_customer_notify']));
         }
         $shipment->register();
         $shipment->getOrder()->setCustomerNoteNotify(!empty($data['send_email']));
         $responseAjax = new \Magento\Framework\DataObject();
         $isNeedCreateLabel = isset($data['create_shipping_label']) && $data['create_shipping_label'];
         if ($isNeedCreateLabel) {
             $this->labelGenerator->create($shipment, $this->_request);
             $responseAjax->setOk(true);
         }
         $this->_saveShipment($shipment);
         if (!empty($data['send_email'])) {
             $this->shipmentSender->send($shipment);
         }
         $shipmentCreatedMessage = __('The shipment has been created.');
         $labelCreatedMessage = __('You created the shipping label.');
         $this->messageManager->addSuccess($isNeedCreateLabel ? $shipmentCreatedMessage . ' ' . $labelCreatedMessage : $shipmentCreatedMessage);
         $this->_objectManager->get('Magento\\Backend\\Model\\Session')->getCommentText(true);
     } catch (\Magento\Framework\Exception\LocalizedException $e) {
         if ($isNeedCreateLabel) {
             $responseAjax->setError(true);
             $responseAjax->setMessage($e->getMessage());
         } else {
             $this->messageManager->addError($e->getMessage());
             $this->_redirect('*/*/new', ['order_id' => $this->getRequest()->getParam('order_id')]);
         }
     } catch (\Exception $e) {
         $this->_objectManager->get('Psr\\Log\\LoggerInterface')->critical($e);
         if ($isNeedCreateLabel) {
             $responseAjax->setError(true);
             $responseAjax->setMessage(__('An error occurred while creating shipping label.'));
         } else {
             $this->messageManager->addError(__('Cannot save shipment.'));
             $this->_redirect('*/*/new', ['order_id' => $this->getRequest()->getParam('order_id')]);
         }
     }
     if ($isNeedCreateLabel) {
         $this->getResponse()->representJson($responseAjax->toJson());
     } else {
         $this->_redirect('sales/order/view', ['order_id' => $shipment->getOrderId()]);
     }
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:77,代码来源:Save.php


注:本文中的Magento\Shipping\Controller\Adminhtml\Order\ShipmentLoader::setOrderId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。