Esempio n. 1
0
 protected function _beforeToHtml()
 {
     // Magento order data
     // ---------------------------------------
     $this->realMagentoOrderId = NULL;
     $magentoOrder = $this->order->getMagentoOrder();
     if (!is_null($magentoOrder)) {
         $this->realMagentoOrderId = $magentoOrder->getRealOrderId();
     }
     // ---------------------------------------
     $data = array('class' => 'primary', 'label' => $this->__('Edit'), 'onclick' => "OrderEditItemObj.openEditShippingAddressPopup({$this->order->getId()});");
     $buttonBlock = $this->createBlock('Magento\\Button')->setData($data);
     $this->setChild('edit_shipping_info', $buttonBlock);
     // ---------------------------------------
     if (!is_null($magentoOrder) && $magentoOrder->hasShipments() && !$this->order->getChildObject()->isPrime()) {
         $url = $this->getUrl('*/order/resubmitShippingInfo', array('id' => $this->order->getId()));
         $data = array('class' => 'primary', 'label' => $this->__('Resend Shipping Information'), 'onclick' => 'setLocation(\'' . $url . '\');');
         $buttonBlock = $this->createBlock('Magento\\Button')->setData($data);
         $this->setChild('resubmit_shipping_info', $buttonBlock);
     }
     // ---------------------------------------
     // Shipping data
     // ---------------------------------------
     /** @var $shippingAddress \Ess\M2ePro\Model\Amazon\Order\ShippingAddress */
     $shippingAddress = $this->order->getShippingAddress();
     $this->shippingAddress = $shippingAddress->getData();
     $this->shippingAddress['country_name'] = $shippingAddress->getCountryName();
     // ---------------------------------------
     // TODO NOT SUPPORTED FEATURES
     // Merchant Fulfillment
     // ---------------------------------------
     //        if (!$this->order->getChildObject()->isCanceled()
     //            && !$this->order->getChildObject()->isPending()
     //            && !$this->order->getChildObject()->isFulfilledByAmazon()
     //            && $this->order->getMarketplace()->getChildObject()->isMerchantFulfillmentAvailable()) {
     //            $orderId = $this->order->getId();
     //            $data = array(
     //                'class'   => '',
     //                'label'   => $this->__('Use Amazon\'s Shipping Services'),
     //                'onclick' => "OrderMerchantFulfillmentObj.getPopupAction({$orderId});",
     //                'style'   => 'margin-top: 3px; margin-left: 6px;'
     //            );
     //            $buttonBlock = $this->getLayout()->createBlock('Magento\Button')->setData($data);
     //            $this->setChild('use_amazons_shipping_services', $buttonBlock);
     //        }
     // ---------------------------------------
     $this->jsUrl->addUrls(['order/getDebugInformation' => $this->getUrl('*/order/getDebugInformation/', array('id' => $this->getRequest()->getParam('id'))), 'getEditShippingAddressForm' => $this->getUrl('*/amazon_order_shippingAddress/edit/', array('id' => $this->getRequest()->getParam('id'))), 'saveShippingAddress' => $this->getUrl('*/amazon_order_shippingAddress/save', array('id' => $this->getRequest()->getParam('id')))]);
     $this->jsPhp->addConstants($this->getHelper('Data')->getClassConstants('\\Ess\\M2ePro\\Controller\\Adminhtml\\Order\\EditItem'));
     $this->setChild('shipping_address', $this->createBlock('Amazon\\Order\\Edit\\ShippingAddress'));
     $this->setChild('item', $this->createBlock('Amazon\\Order\\View\\Item'));
     $this->setChild('item_edit', $this->createBlock('Order\\Item\\Edit'));
     $this->setChild('log', $this->createBlock('Order\\View\\Log\\Grid'));
     return parent::_beforeToHtml();
 }
Esempio n. 2
0
 private function processOrder(\Ess\M2ePro\Model\Order $order)
 {
     if ($order->getChildObject()->isPaymentCompleted()) {
         // unpaid order became paid
         // immediately created magento order should be canceled
         // and new magento order should be created instead
         if ($order->canCancelMagentoOrder()) {
             $message = 'Payment Status was updated to Paid on eBay. ' . 'As Magento Order #%order_id% can have wrong data, it have to be cancelled.';
             $order->addWarningLog($message, array('!order_id' => $order->getMagentoOrder()->getRealOrderId()));
             try {
                 $order->cancelMagentoOrder();
             } catch (\Exception $e) {
                 // magento order was not cancelled
                 // do not create new magento order to prevent oversell
                 return;
             }
         }
         $this->clearOrder($order);
         $this->createMagentoOrder($order);
     } else {
         // unpaid order did not become paid
         // immediately created magento order should be canceled
         // and unpaid item process should be opened for each order item
         if ($order->canCancelMagentoOrder()) {
             $message = 'Payment Status was not updated to Paid. Magento Order #%order_id% ' . 'have to be cancelled according to Account\'s Automatic Cancellation Setting.';
             $order->addWarningLog($message, array('!order_id' => $order->getMagentoOrder()->getRealOrderId()));
             try {
                 $order->cancelMagentoOrder();
             } catch (\Exception $e) {
             }
         }
         $this->openUnpaidItemProcess($order);
     }
 }