We will be off from 27/1 (Monday) to 31/1 (Friday) (GMT +7) for our Tet Holiday (Lunar New Year) in our country

Commit ffa1b79d authored by Rik ter Beek's avatar Rik ter Beek Committed by GitHub

Merge pull request #295 from ho-nl-fork/order-repository

B: Use order repository to load order instead of orderFactory
parents d1e99d66 fde9bd90
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
namespace Adyen\Payment\Model; namespace Adyen\Payment\Model;
use Magento\Framework\Api\SearchCriteriaBuilder;
use Magento\Framework\Webapi\Exception; use Magento\Framework\Webapi\Exception;
use Magento\Sales\Model\Order\Email\Sender\OrderSender; use Magento\Sales\Model\Order\Email\Sender\OrderSender;
use Magento\Sales\Model\Order\Email\Sender\InvoiceSender; use Magento\Sales\Model\Order\Email\Sender\InvoiceSender;
...@@ -30,6 +31,7 @@ use Magento\Framework\App\Area; ...@@ -30,6 +31,7 @@ use Magento\Framework\App\Area;
use Magento\Framework\App\AreaList; use Magento\Framework\App\AreaList;
use Magento\Framework\Phrase\Renderer\Placeholder; use Magento\Framework\Phrase\Renderer\Placeholder;
use Magento\Framework\Phrase; use Magento\Framework\Phrase;
use Magento\Sales\Model\OrderRepository;
class Cron class Cron
{ {
...@@ -192,6 +194,16 @@ class Cron ...@@ -192,6 +194,16 @@ class Cron
*/ */
protected $_orderStatusCollection; protected $_orderStatusCollection;
/**
* @var SearchCriteriaBuilder
*/
private $searchCriteriaBuilder;
/**
* @var OrderRepository
*/
private $orderRepository;
/** /**
* Cron constructor. * Cron constructor.
* *
...@@ -211,6 +223,8 @@ class Cron ...@@ -211,6 +223,8 @@ class Cron
* @param InvoiceFactory $adyenInvoiceFactory * @param InvoiceFactory $adyenInvoiceFactory
* @param AreaList $areaList * @param AreaList $areaList
* @param \Magento\Sales\Model\ResourceModel\Order\Status\CollectionFactory $orderStatusCollection * @param \Magento\Sales\Model\ResourceModel\Order\Status\CollectionFactory $orderStatusCollection
* @param SearchCriteriaBuilder $searchCriteriaBuilder
* @param OrderRepository $orderRepository
*/ */
public function __construct( public function __construct(
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
...@@ -228,7 +242,9 @@ class Cron ...@@ -228,7 +242,9 @@ class Cron
\Adyen\Payment\Model\ResourceModel\Order\Payment\CollectionFactory $adyenOrderPaymentCollectionFactory, \Adyen\Payment\Model\ResourceModel\Order\Payment\CollectionFactory $adyenOrderPaymentCollectionFactory,
\Adyen\Payment\Model\InvoiceFactory $adyenInvoiceFactory, \Adyen\Payment\Model\InvoiceFactory $adyenInvoiceFactory,
AreaList $areaList, AreaList $areaList,
\Magento\Sales\Model\ResourceModel\Order\Status\CollectionFactory $orderStatusCollection \Magento\Sales\Model\ResourceModel\Order\Status\CollectionFactory $orderStatusCollection,
SearchCriteriaBuilder $searchCriteriaBuilder,
OrderRepository $orderRepository
) )
{ {
$this->_scopeConfig = $scopeConfig; $this->_scopeConfig = $scopeConfig;
...@@ -247,6 +263,8 @@ class Cron ...@@ -247,6 +263,8 @@ class Cron
$this->_adyenInvoiceFactory = $adyenInvoiceFactory; $this->_adyenInvoiceFactory = $adyenInvoiceFactory;
$this->_areaList = $areaList; $this->_areaList = $areaList;
$this->_orderStatusCollection = $orderStatusCollection; $this->_orderStatusCollection = $orderStatusCollection;
$this->searchCriteriaBuilder = $searchCriteriaBuilder;
$this->orderRepository = $orderRepository;
} }
/** /**
...@@ -331,8 +349,17 @@ class Cron ...@@ -331,8 +349,17 @@ class Cron
// get order // get order
$incrementId = $notification->getMerchantReference(); $incrementId = $notification->getMerchantReference();
$this->_order = $this->_orderFactory->create()->loadByIncrementId($incrementId); $searchCriteria = $this->searchCriteriaBuilder
if (!$this->_order->getId()) { ->addFilter('increment_id', $incrementId, 'eq')
->create();
$orderList = $this->orderRepository->getList($searchCriteria)->getItems();
/** @var \Magento\Sales\Model\Order $order */
$order = reset($orderList);
$this->_order = $order;
if (!$this->_order) {
// order does not exists remove from queue // order does not exists remove from queue
$notification->delete(); $notification->delete();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment