Beispiel #1
0
 private function processExistShipment(\Magento\Shipping\Block\Adminhtml\View $block)
 {
     $shipmentId = $block->getRequest()->getParam('shipment_id');
     if (empty($shipmentId)) {
         return;
     }
     /** @var \Magento\Sales\Model\Order\Shipment $shipment */
     $shipment = $this->shipmentRepository->get((int) $shipmentId);
     try {
         /** @var \Ess\M2ePro\Model\Order $order */
         $order = $this->amazonFactory->getObjectLoaded('Order', (int) $shipment->getOrderId(), 'magento_order_id');
     } catch (\Exception $exception) {
         return;
     }
     if (is_null($order) || !$order->getId()) {
         return;
     }
     if (!$order->isMagentoShipmentCreatedByOrder($shipment)) {
         return;
     }
     /** @var \Ess\M2ePro\Model\Amazon\Order $amazonOrder */
     $amazonOrder = $order->getChildObject();
     if (!$amazonOrder->isMerchantFulfillmentApplied() || !$amazonOrder->getData('merchant_fulfillment_label')) {
         return;
     }
     return;
     //TODO unsupported feature
     //        $getLabelUrl = $block->getUrl(
     //            'M2ePro/common_amazon_order_merchantFulfillment/getLabel',
     //            array('order_id' => $order->getId())
     //        );
     //
     //        $block->updateButton('print', 'onclick', 'window.open(\''.$getLabelUrl.'\')');
 }
 /**
  * @param \Magento\Shipping\Block\Adminhtml\View $subject
  */
 public function beforeGetBackUrl(\Magento\Shipping\Block\Adminhtml\View $subject)
 {
     if ($subject->getRequest()->getFullActionName() == 'adminhtml_order_shipment_view' && $this->_shipmentHelper->isMercadoEnviosMethod($subject->getShipment()->getOrder()->getShippingMethod())) {
         $subject->addButton('custom_button', ['label' => 'Print shipping label', 'onclick' => 'window.open(\' ' . $this->_shipmentHelper->getTrackingPrintUrl($subject->getRequest()->getParam('shipment_id')) . '\')', 'class' => 'go']);
     }
 }