Commit 35d88798 authored by Giorgos Adam's avatar Giorgos Adam

Enable translations for Adyen cronjob, useful for order confirmation email sending for Magento 2.1

parent 506825ca
...@@ -25,6 +25,8 @@ namespace Adyen\Payment\Model; ...@@ -25,6 +25,8 @@ namespace Adyen\Payment\Model;
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\Framework\App\Area;
use Magento\Framework\ObjectManagerInterface;
class Cron class Cron
{ {
...@@ -162,6 +164,11 @@ class Cron ...@@ -162,6 +164,11 @@ class Cron
*/ */
protected $_adyenOrderPaymentCollectionFactory; protected $_adyenOrderPaymentCollectionFactory;
/**
* @var ObjectManagerInterface
*/
protected $_objectManager;
/** /**
* Cron constructor. * Cron constructor.
* *
...@@ -177,6 +184,7 @@ class Cron ...@@ -177,6 +184,7 @@ class Cron
* @param Api\PaymentRequest $paymentRequest * @param Api\PaymentRequest $paymentRequest
* @param Order\PaymentFactory $adyenOrderPaymentFactory * @param Order\PaymentFactory $adyenOrderPaymentFactory
* @param Resource\Order\Payment\CollectionFactory $adyenOrderPaymentCollectionFactory * @param Resource\Order\Payment\CollectionFactory $adyenOrderPaymentCollectionFactory
* @param ObjectManagerInterface $objectManager
*/ */
public function __construct( public function __construct(
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
...@@ -190,7 +198,8 @@ class Cron ...@@ -190,7 +198,8 @@ class Cron
\Adyen\Payment\Model\Resource\Billing\Agreement\CollectionFactory $billingAgreementCollectionFactory, \Adyen\Payment\Model\Resource\Billing\Agreement\CollectionFactory $billingAgreementCollectionFactory,
\Adyen\Payment\Model\Api\PaymentRequest $paymentRequest, \Adyen\Payment\Model\Api\PaymentRequest $paymentRequest,
\Adyen\Payment\Model\Order\PaymentFactory $adyenOrderPaymentFactory, \Adyen\Payment\Model\Order\PaymentFactory $adyenOrderPaymentFactory,
\Adyen\Payment\Model\Resource\Order\Payment\CollectionFactory $adyenOrderPaymentCollectionFactory \Adyen\Payment\Model\Resource\Order\Payment\CollectionFactory $adyenOrderPaymentCollectionFactory,
ObjectManagerInterface $objectManager
) { ) {
$this->_scopeConfig = $scopeConfig; $this->_scopeConfig = $scopeConfig;
$this->_adyenLogger = $adyenLogger; $this->_adyenLogger = $adyenLogger;
...@@ -204,6 +213,7 @@ class Cron ...@@ -204,6 +213,7 @@ class Cron
$this->_adyenPaymentRequest = $paymentRequest; $this->_adyenPaymentRequest = $paymentRequest;
$this->_adyenOrderPaymentFactory = $adyenOrderPaymentFactory; $this->_adyenOrderPaymentFactory = $adyenOrderPaymentFactory;
$this->_adyenOrderPaymentCollectionFactory = $adyenOrderPaymentCollectionFactory; $this->_adyenOrderPaymentCollectionFactory = $adyenOrderPaymentCollectionFactory;
$this->_objectManager = $objectManager;
} }
/** /**
...@@ -212,6 +222,12 @@ class Cron ...@@ -212,6 +222,12 @@ class Cron
*/ */
public function processNotification() public function processNotification()
{ {
// needed for Magento < 2.2.0 https://github.com/magento/magento2/pull/8413
$areaList = $this->_objectManager->get(\Magento\Framework\App\AreaList::class);
if($areaList) {
$areaList->getArea(Area::AREA_CRONTAB)->load(Area::PART_TRANSLATE);
}
$this->_order = null; $this->_order = null;
// execute notifications from 2 minute or earlier because order could not yet been created by magento // execute notifications from 2 minute or earlier because order could not yet been created by magento
......
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