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


PHP Model\OrderFactory类代码示例

本文整理汇总了PHP中Magento\Sales\Model\OrderFactory的典型用法代码示例。如果您正苦于以下问题:PHP OrderFactory类的具体用法?PHP OrderFactory怎么用?PHP OrderFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: _getOrder

 /**
  * Return order instance loaded by increment id
  *
  * @return Order
  */
 protected function _getOrder()
 {
     if (empty($this->_order)) {
         $orderId = $this->getRequest()->getParam('orderID');
         $this->_order = $this->_salesOrderFactory->create()->loadByIncrementId($orderId);
     }
     return $this->_order;
 }
开发者ID:Atlis,项目名称:docker-magento2,代码行数:13,代码来源:Api.php

示例2: _getOrder

 /**
  * Get order object
  *
  * @return \Magento\Sales\Model\Order
  */
 protected function _getOrder()
 {
     if (!$this->_order) {
         $incrementId = $this->_getCheckout()->getLastRealOrderId();
         $this->_orderFactory = $this->_objectManager->get('Magento\\Sales\\Model\\OrderFactory');
         $this->_order = $this->_orderFactory->create()->loadByIncrementId($incrementId);
     }
     return $this->_order;
 }
开发者ID:Adyen,项目名称:adyen-magento2,代码行数:14,代码来源:Redirect.php

示例3: _getOrder

 /**
  * Return order instance with loaded information by increment id
  *
  * @return \Magento\Sales\Model\Order
  */
 protected function _getOrder()
 {
     if ($this->getOrder()) {
         $order = $this->getOrder();
     } elseif ($this->_checkoutSession->getLastRealOrderId()) {
         $order = $this->_salesOrderFactory->create()->loadByIncrementId($this->_checkoutSession->getLastRealOrderId());
     } else {
         return null;
     }
     return $order;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:16,代码来源:Placeform.php

示例4: __construct

 /**
  * Redirect constructor.
  *
  * @param \Magento\Framework\View\Element\Template\Context $context
  * @param array $data
  * @param \Magento\Sales\Model\OrderFactory $orderFactory
  * @param \Magento\Checkout\Model\Session $checkoutSession
  * @param \Adyen\Payment\Helper\Data $adyenHelper
  */
 public function __construct(\Magento\Framework\View\Element\Template\Context $context, array $data = [], \Magento\Sales\Model\OrderFactory $orderFactory, \Magento\Checkout\Model\Session $checkoutSession, \Adyen\Payment\Helper\Data $adyenHelper, \Magento\Framework\Locale\ResolverInterface $resolver, \Adyen\Payment\Logger\AdyenLogger $adyenLogger)
 {
     $this->_orderFactory = $orderFactory;
     $this->_checkoutSession = $checkoutSession;
     parent::__construct($context, $data);
     $this->_adyenHelper = $adyenHelper;
     $this->_resolver = $resolver;
     $this->_adyenLogger = $adyenLogger;
     if (!$this->_order) {
         $incrementId = $this->_getCheckout()->getLastRealOrderId();
         $this->_order = $this->_orderFactory->create()->loadByIncrementId($incrementId);
     }
 }
开发者ID:Adyen,项目名称:adyen-magento2,代码行数:22,代码来源:Redirect.php

示例5: afterGetOrders

 public function afterGetOrders(\Magento\Sales\Block\Order\History $subject, $result)
 {
     $old = $this->_oldCollectionFactory->create();
     $blank = $this->_blankCollectionFactory->create();
     //$this->_logger->debug(print_r($blank->getAllIds(), true));
     // add orders from new website to blank collection , first
     foreach ($result as $new) {
         $blank->addItem($new);
     }
     // add orders from old website to blank collection
     foreach ($old as $o) {
         //$this->_logger->debug(print_r($o->getData(), true));
         $clone = $this->orderFactory->create();
         $clone->setId($o->getOrderId());
         $clone->setStatus(trim($o->getStatus()));
         $clone->setState(trim($o->getState()));
         $clone->setOrderId($o->getOrderId());
         $clone->setRealOrderId($o->getIncrementId());
         $clone->setCustomerId($o->getCustomerId());
         $clone->setIsFromImport(1);
         $blank->addItem($clone);
     }
     foreach ($blank as $b) {
         //$this->_logger->debug(print_r($b->getData(), true));
     }
     //$this->_logger->debug(print_r($blank->getAllIds(), true));
     return $blank;
 }
开发者ID:vuleticd,项目名称:OrderHistory,代码行数:28,代码来源:HistoryPlugin.php

示例6: save

 /**
  * {@inheritDoc}
  */
 public function save($orderId, \Magento\GiftMessage\Api\Data\MessageInterface $giftMessage)
 {
     /** @var \Magento\Sales\Api\Data\OrderInterface $order */
     $order = $this->orderFactory->create()->load($orderId);
     if (!$order->getEntityId()) {
         throw new NoSuchEntityException(__('There is no order with provided id'));
     }
     if (0 == $order->getTotalItemCount()) {
         throw new InputException(__('Gift Messages is not applicable for empty order'));
     }
     if ($order->getIsVirtual()) {
         throw new InvalidTransitionException(__('Gift Messages is not applicable for virtual products'));
     }
     if (!$this->helper->isMessagesAllowed('order', $order, $this->storeManager->getStore())) {
         throw new CouldNotSaveException(__('Gift Message is not available'));
     }
     $message = [];
     $message[$orderId] = ['type' => 'order', $giftMessage::CUSTOMER_ID => $giftMessage->getCustomerId(), $giftMessage::SENDER => $giftMessage->getSender(), $giftMessage::RECIPIENT => $giftMessage->getRecipient(), $giftMessage::MESSAGE => $giftMessage->getMessage()];
     $this->giftMessageSaveModel->setGiftmessages($message);
     try {
         $this->giftMessageSaveModel->saveAllInOrder();
     } catch (\Exception $e) {
         throw new CouldNotSaveException(__('Could not add gift message to order: "%1"', $e->getMessage()), $e);
     }
     return true;
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:29,代码来源:OrderRepository.php

示例7: _reorder

 private function _reorder($orderId)
 {
     /** @var \Magento\Sales\Model\Order $order */
     $order = $this->_orderFactory->create()->loadByIncrementId($orderId);
     /** @var \Magento\Framework\Controller\Result\Redirect $resultRedirect */
     $resultRedirect = $this->resultRedirectFactory->create();
     /* @var $cart \Magento\Checkout\Model\Cart */
     $cart = $this->_objectManager->get('Magento\\Checkout\\Model\\Cart');
     $cart->truncate();
     $items = $order->getItemsCollection();
     foreach ($items as $item) {
         try {
             $cart->addOrderItem($item);
         } catch (\Magento\Framework\Exception\LocalizedException $e) {
             if ($this->_objectManager->get('Magento\\Checkout\\Model\\Session')->getUseNotice(true)) {
                 $this->messageManager->addNotice($e->getMessage());
             } else {
                 $this->messageManager->addError($e->getMessage());
             }
             return $resultRedirect->setPath('*/*/history');
         } catch (\Exception $e) {
             $this->messageManager->addException($e, __('We can\'t add this item to your shopping cart right now.'));
             return $resultRedirect->setPath('checkout/cart');
         }
     }
     $cart->save();
     return $resultRedirect->setPath('checkout/cart');
 }
开发者ID:vkerkhoff,项目名称:magento2-plugin,代码行数:28,代码来源:Index.php

示例8: _getOrder

 protected function _getOrder($incrementId = null)
 {
     if (!$this->_order) {
         $incrementId = $incrementId ? $incrementId : $this->_getCheckout()->getLastRealOrderId();
         $this->_order = $this->_orderFactory->create()->loadByIncrementId($incrementId);
     }
     return $this->_order;
 }
开发者ID:vuleticd,项目名称:vuleticd_assist2,代码行数:8,代码来源:Cancel.php

示例9: execute

 /**
  * Record order shipping information after order is placed
  *
  * @param EventObserver $observer
  * @return void
  */
 public function execute(EventObserver $observer)
 {
     if ($this->shipperDataHelper->getConfigValue('carriers/shipper/active')) {
         $order = $this->orderFactory->create()->loadByIncrementId($this->checkoutSession->getLastRealOrderId());
         if ($order->getIncrementId()) {
             $this->recordOrder($order);
         }
     }
 }
开发者ID:shipperhq,项目名称:module-shipper,代码行数:15,代码来源:RecordOrder.php

示例10: testGetSuccessOrderUrl

 public function testGetSuccessOrderUrl()
 {
     $orderMock = $this->getMock('Magento\\Sales\\Model\\Order', ['loadByIncrementId', 'getId', '__wakeup'], [], '', false);
     $orderMock->expects($this->once())->method('loadByIncrementId')->with('invoice number')->willReturnSelf();
     $orderMock->expects($this->once())->method('getId')->willReturn('order id');
     $this->orderFactoryMock->expects($this->once())->method('create')->willReturn($orderMock);
     $this->urlBuilderMock->expects($this->once())->method('getUrl')->with('sales/order/view', ['order_id' => 'order id'])->willReturn('some value');
     $this->assertEquals('some value', $this->dataHelper->getSuccessOrderUrl(['x_invoice_num' => 'invoice number', 'some param']));
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:9,代码来源:DataTest.php

示例11: _getCustomerProductCollection

 /**
  * Get a collection of all products in the orders
  *
  * @param $ordersCollection
  * @return array
  */
 protected function _getCustomerProductCollection($ordersCollection)
 {
     $purchasedProducts = [];
     foreach ($ordersCollection as $order) {
         $order = $this->_orderFactory->create()->load($order['entity_id']);
         $itemCollection = $order->getItems();
         foreach ($itemCollection as $item) {
             $purchasedProducts[$order['customer_id']][] = $item->getProductId();
         }
     }
     $this->_productCollection = $purchasedProducts;
     return $purchasedProducts;
 }
开发者ID:richdynamix,项目名称:personalised-products,代码行数:19,代码来源:AbstractOrdersCommand.php

示例12: execute

 public function execute()
 {
     $skipFraudDetection = false;
     \Paynl\Config::setApiToken($this->_config->getApiToken());
     $params = $this->getRequest()->getParams();
     if (!isset($params['order_id'])) {
         $this->_logger->critical('Exchange: order_id is not set in the request', $params);
         return $this->_result->setContents('FALSE| order_id is not set in the request');
     }
     try {
         $transaction = \Paynl\Transaction::get($params['order_id']);
     } catch (\Exception $e) {
         $this->_logger->critical($e, $params);
         return $this->_result->setContents('FALSE| Error fetching transaction. ' . $e->getMessage());
     }
     if ($transaction->isPending()) {
         return $this->_result->setContents("TRUE| Ignoring pending");
     }
     $orderId = $transaction->getDescription();
     $order = $this->_orderFactory->create()->loadByIncrementId($orderId);
     if (empty($order)) {
         $this->_logger->critical('Cannot load order: ' . $orderId);
         return $this->_result->setContents('FALSE| Cannot load order');
     }
     if ($order->getTotalDue() <= 0) {
         $this->_logger->debug('Total due <= 0, so iam not touching the status of the order: ' . $orderId);
         return $this->_result->setContents('TRUE| Total due <= 0, so iam not touching the status of the order');
     }
     if ($transaction->isPaid()) {
         $payment = $order->getPayment();
         $payment->setTransactionId($transaction->getId());
         $payment->setCurrencyCode($transaction->getPaidCurrency());
         $payment->setIsTransactionClosed(0);
         $payment->registerCaptureNotification($transaction->getPaidCurrencyAmount(), $skipFraudDetection);
         $order->save();
         // notify customer
         $invoice = $payment->getCreatedInvoice();
         if ($invoice && !$order->getEmailSent()) {
             $this->_orderSender->send($order);
             $order->addStatusHistoryComment(__('New order email sent'))->setIsCustomerNotified(true)->save();
         }
         if ($invoice && !$invoice->getEmailSent()) {
             $this->_invoiceSender->send($invoice);
             $order->addStatusHistoryComment(__('You notified customer about invoice #%1.', $invoice->getIncrementId()))->setIsCustomerNotified(true)->save();
         }
         return $this->_result->setContents("TRUE| PAID");
     } elseif ($transaction->isCanceled()) {
         $order->cancel()->save();
         return $this->_result->setContents("TRUE| CANCELED");
     }
 }
开发者ID:paynl,项目名称:magento2-plugin,代码行数:51,代码来源:Exchange.php

示例13: execute

 /**
  * Record order shipping information after order is placed
  *
  * @param EventObserver $observer
  * @return void
  */
 public function execute(EventObserver $observer)
 {
     if ($this->shipperDataHelper->getConfigValue('carriers/shipper/active')) {
         $orderIds = $observer->getEvent()->getOrderIds();
         if (empty($orderIds) || !is_array($orderIds)) {
             return;
         }
         foreach ($orderIds as $orderId) {
             $order = $this->orderFactory->create()->loadByIncrementId($orderId);
             if ($order->getIncrementId()) {
                 $this->recordOrder($order);
             }
         }
     }
 }
开发者ID:shipperhq,项目名称:module-shipper,代码行数:21,代码来源:RecordMultiOrder.php

示例14: prepareBlockData

 /**
  * Prepares block data
  *
  * @return void
  */
 protected function prepareBlockData()
 {
     $s2p_transaction = $this->_s2pTransaction->create();
     $order = $this->_orderFactory->create();
     $module_settings = $this->_s2pModel->getFullConfigArray();
     $transaction_obj = false;
     $error_message = '';
     $merchant_transaction_id = 0;
     if (($status_code = $this->_helper->getParam('data', null)) === null) {
         $error_message = __('Transaction status not provided.');
     } elseif (!($merchant_transaction_id = $this->_helper->getParam('MerchantTransactionID', '')) or !($merchant_transaction_id = $this->_helper->convert_from_demo_merchant_transaction_id($merchant_transaction_id))) {
         $error_message = __('Couldn\'t extract transaction information.');
     } elseif (!$s2p_transaction->loadByMerchantTransactionId($merchant_transaction_id) or !$s2p_transaction->getID()) {
         $error_message = __('Transaction not found in database.');
     } elseif (!$order->loadByIncrementId($merchant_transaction_id) or !$order->getEntityId()) {
         $error_message = __('Order not found in database.');
     }
     $status_code = intval($status_code);
     if (empty($status_code)) {
         $status_code = Smart2Pay::S2P_STATUS_FAILED;
     }
     $transaction_extra_data = [];
     $transaction_details_titles = [];
     if (in_array($s2p_transaction->getMethodId(), [\Smart2Pay\GlobalPay\Model\Smart2Pay::PAYMENT_METHOD_BT, \Smart2Pay\GlobalPay\Model\Smart2Pay::PAYMENT_METHOD_SIBS])) {
         if ($transaction_details_titles = \Smart2Pay\GlobalPay\Helper\Smart2Pay::transaction_logger_params_to_title() and is_array($transaction_details_titles)) {
             if (!($all_params = $this->_helper->getParams())) {
                 $all_params = [];
             }
             foreach ($transaction_details_titles as $key => $title) {
                 if (!array_key_exists($key, $all_params)) {
                     continue;
                 }
                 $transaction_extra_data[$key] = $all_params[$key];
             }
         }
     }
     $result_message = __('Transaction status is unknown.');
     if (empty($error_message)) {
         //map all statuses to known Magento statuses (message_data_2, message_data_4, message_data_3 and message_data_7)
         $status_id_to_string = array(Smart2Pay::S2P_STATUS_OPEN => Smart2Pay::S2P_STATUS_PENDING_PROVIDER, Smart2Pay::S2P_STATUS_SUCCESS => Smart2Pay::S2P_STATUS_SUCCESS, Smart2Pay::S2P_STATUS_CANCELLED => Smart2Pay::S2P_STATUS_CANCELLED, Smart2Pay::S2P_STATUS_FAILED => Smart2Pay::S2P_STATUS_FAILED, Smart2Pay::S2P_STATUS_EXPIRED => Smart2Pay::S2P_STATUS_FAILED, Smart2Pay::S2P_STATUS_PENDING_CUSTOMER => Smart2Pay::S2P_STATUS_PENDING_PROVIDER, Smart2Pay::S2P_STATUS_PENDING_PROVIDER => Smart2Pay::S2P_STATUS_PENDING_PROVIDER, Smart2Pay::S2P_STATUS_SUBMITTED => Smart2Pay::S2P_STATUS_PENDING_PROVIDER, Smart2Pay::S2P_STATUS_PROCESSING => Smart2Pay::S2P_STATUS_PENDING_PROVIDER, Smart2Pay::S2P_STATUS_AUTHORIZED => Smart2Pay::S2P_STATUS_PENDING_PROVIDER, Smart2Pay::S2P_STATUS_APPROVED => Smart2Pay::S2P_STATUS_PENDING_PROVIDER, Smart2Pay::S2P_STATUS_CAPTURED => Smart2Pay::S2P_STATUS_PENDING_PROVIDER, Smart2Pay::S2P_STATUS_REJECTED => Smart2Pay::S2P_STATUS_FAILED, Smart2Pay::S2P_STATUS_PENDING_CAPTURE => Smart2Pay::S2P_STATUS_PENDING_PROVIDER, Smart2Pay::S2P_STATUS_EXCEPTION => Smart2Pay::S2P_STATUS_PENDING_PROVIDER, Smart2Pay::S2P_STATUS_PENDING_CANCEL => Smart2Pay::S2P_STATUS_PENDING_PROVIDER, Smart2Pay::S2P_STATUS_REVERSED => Smart2Pay::S2P_STATUS_PENDING_PROVIDER, Smart2Pay::S2P_STATUS_COMPLETED => Smart2Pay::S2P_STATUS_SUCCESS, Smart2Pay::S2P_STATUS_PROCESSING => Smart2Pay::S2P_STATUS_PENDING_PROVIDER, Smart2Pay::S2P_STATUS_DISPUTED => Smart2Pay::S2P_STATUS_PENDING_PROVIDER, Smart2Pay::S2P_STATUS_CHARGEBACK => Smart2Pay::S2P_STATUS_PENDING_PROVIDER);
         if (isset($module_settings['message_data_' . $status_code])) {
             $result_message = $module_settings['message_data_' . $status_code];
         } elseif (!empty($status_id_to_string[$status_code]) and isset($module_settings['message_data_' . $status_id_to_string[$status_code]])) {
             $result_message = $module_settings['message_data_' . $status_id_to_string[$status_code]];
         }
     }
     $this->addData(['error_message' => $error_message, 'result_message' => $result_message, 'transaction_data' => $s2p_transaction->getData(), 'transaction_extra_data' => $transaction_extra_data, 'transaction_details_title' => $transaction_details_titles, 'is_order_visible' => $this->isVisible($order), 'view_order_url' => $this->getUrl('sales/order/view/', ['order_id' => $order->getEntityId()]), 'can_view_order' => $this->canViewOrder($order), 'order_id' => $order->getIncrementId()]);
 }
开发者ID:smart2pay,项目名称:magento20,代码行数:53,代码来源:Finish.php

示例15: _getOrder

 /**
  * @param $incrementId
  * @return \Magento\Sales\Model\Order
  */
 protected function _getOrder($incrementId)
 {
     if (!$this->_order) {
         $this->_order = $this->_orderFactory->create()->loadByIncrementId($incrementId);
     }
     return $this->_order;
 }
开发者ID:Adyen,项目名称:adyen-magento2,代码行数:11,代码来源:ResultPos.php


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