Ejemplo 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();
 }
Ejemplo n.º 2
0
 private function addSessionErrorMessage(\Ess\M2ePro\Model\Order $order)
 {
     if ($order->isComponentModeEbay()) {
         $url = $this->urlBuilder->getUrl('*/ebay_order_log/index', array('order_id' => $order->getId()));
     } else {
         $url = $this->urlBuilder->getUrl('*/amazon_order_log/index', array('order_id' => $order->getId()));
     }
     $chanelTitle = $order->getComponentTitle();
     // M2ePro\TRANSLATIONS
     // Shipping Status for %chanel_title% Order was not updated. View <a href="%url%" target="_blank" >Order Log</a> for more details.
     $message = $this->getHelper('Module\\Translation')->__('Shipping Status for %chanel_title% Order was not updated.' . ' View <a href="%url% target="_blank" >Order Log</a>' . ' for more details.', $chanelTitle, $url);
     $this->messageManager->addError($message);
 }
Ejemplo n.º 3
0
 private function getItemsToShip(\Ess\M2ePro\Model\Order $order, \Magento\Sales\Model\Order\Shipment $shipment)
 {
     $productTypesNotAllowedByDefault = array(\Magento\Catalog\Model\Product\Type::TYPE_BUNDLE, \Magento\GroupedProduct\Model\Product\Type\Grouped::TYPE_CODE);
     $items = array();
     $allowedItems = array();
     foreach ($shipment->getAllItems() as $shipmentItem) {
         /** @var $shipmentItem \Magento\Sales\Model\Order\Shipment\Item */
         $orderItem = $shipmentItem->getOrderItem();
         $parentOrderItemId = $orderItem->getParentItemId();
         if (!is_null($parentOrderItemId)) {
             !in_array($parentOrderItemId, $allowedItems) && ($allowedItems[] = $parentOrderItemId);
             continue;
         }
         if (!in_array($orderItem->getProductType(), $productTypesNotAllowedByDefault)) {
             $allowedItems[] = $orderItem->getId();
         }
         $additionalData = $orderItem->getAdditionalData();
         $additionalData = is_string($additionalData) ? @unserialize($additionalData) : array();
         $itemId = $transactionId = null;
         $orderItemDataIdentifier = \Ess\M2ePro\Helper\Data::CUSTOM_IDENTIFIER;
         if (isset($additionalData['ebay_item_id']) && isset($additionalData['ebay_transaction_id'])) {
             // backward compatibility with versions 5.0.4 or less
             $itemId = $additionalData['ebay_item_id'];
             $transactionId = $additionalData['ebay_transaction_id'];
         } elseif (isset($additionalData[$orderItemDataIdentifier]['items'])) {
             if (!is_array($additionalData[$orderItemDataIdentifier]['items']) || count($additionalData[$orderItemDataIdentifier]['items']) != 1) {
                 return null;
             }
             if (isset($additionalData[$orderItemDataIdentifier]['items'][0]['item_id'])) {
                 $itemId = $additionalData[$orderItemDataIdentifier]['items'][0]['item_id'];
             }
             if (isset($additionalData[$orderItemDataIdentifier]['items'][0]['transaction_id'])) {
                 $transactionId = $additionalData[$orderItemDataIdentifier]['items'][0]['transaction_id'];
             }
         }
         if (is_null($itemId) || is_null($transactionId)) {
             continue;
         }
         $item = $this->ebayFactory->getObject('Order\\Item')->getCollection()->addFieldToFilter('order_id', $order->getId())->addFieldToFilter('item_id', $itemId)->addFieldToFilter('transaction_id', $transactionId)->getFirstItem();
         if (!$item->getId()) {
             continue;
         }
         $items[$orderItem->getId()] = $item;
     }
     $resultItems = array();
     foreach ($items as $orderItemId => $item) {
         if (!in_array($orderItemId, $allowedItems)) {
             continue;
         }
         $resultItems[] = $item;
     }
     return $resultItems;
 }
Ejemplo n.º 4
0
 private function getOrderItemsForUnpaidItemProcess(\Ess\M2ePro\Model\Order $order)
 {
     /** @var \Ess\M2ePro\Model\ResourceModel\Order\Item\Collection $collection */
     $collection = $this->ebayFactory->getObject('Order\\Item')->getCollection();
     $collection->addFieldToFilter('order_id', $order->getId());
     $collection->addFieldToFilter('unpaid_item_process_state', \Ess\M2ePro\Model\Ebay\Order\Item::UNPAID_ITEM_PROCESS_NOT_OPENED);
     return $collection->getItems();
 }
Ejemplo n.º 5
0
 private function addSessionErrorMessage(\Ess\M2ePro\Model\Order $order)
 {
     $url = $this->urlBuilder->getUrl('M2ePro/adminhtml_amazon_order_log/index', array('order_id' => $order->getId()));
     // M2ePro\TRANSLATIONS
     // Cancel for Amazon Order was not performed. View <a href="%url%" target="_blank" >order log</a> for more details.
     $message = $this->getHelper('Module\\Translation')->__('Cancel for Amazon Order was not performed.' . ' View <a href="%url% target="_blank" >order log</a>' . ' for more details.', $url);
     $this->messageManager->addError($message);
 }