|
Apache/2.4.41 (Ubuntu) Linux vmi616275.contaboserver.net 5.4.0-84-generic #94-Ubuntu SMP Thu Aug 26 20:27:37 UTC 2021 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) server ip : 62.171.164.128 | your ip : 127.0.0.1 safemode OFF > / home / a / home / dev2.destoffenstraat.com / app / code / TIG / PostNL / Plugin / Order / |
Filename | /home/a/home/dev2.destoffenstraat.com/app/code/TIG/PostNL/Plugin/Order/AsyncPlugin.php |
Size | 4.08 kb |
Permission | rwxrwxrwx |
Owner | root : root |
Create time | 21-Aug-2025 12:26 |
Last modified | 20-Dec-2022 13:13 |
Last accessed | 22-Aug-2025 21:51 |
Actions | edit | rename | delete | download (gzip) |
View | text | code | image |
<?php
/**
*
* ..::..
* ..::::::::::::..
* ::'''''':''::'''''::
* ::.. ..: : ....::
* :::: ::: : : ::
* :::: ::: : ''' ::
* ::::..:::..::.....::
* ''::::::::::::''
* ''::''
*
*
* NOTICE OF LICENSE
*
* This source file is subject to the Creative Commons License.
* It is available through the world-wide-web at this URL:
* http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
* If you are unable to obtain it through the world-wide-web, please send an email
* to servicedesk@totalinternetgroup.nl so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this module to newer
* versions in the future. If you wish to customize this module for your
* needs please contact servicedesk@tig.nl for more information.
*
* @copyright Copyright (c) Total Internet Group B.V. https://tig.nl/copyright
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
*/
namespace TIG\PostNL\Plugin\Order;
use Magento\Framework\App\ResourceConnection;
use Magento\Framework\Model\ResourceModel\Db\Context;
use Magento\Sales\Model\ResourceModel\Grid;
use Magento\Sales\Model\ResourceModel\Provider\NotSyncedDataProviderInterface;
use TIG\PostNL\Model\OrderRepository;
class AsyncPlugin extends Grid
{
/**
* @var array
*/
private $notSyncedIds;
/**
* @var NotSyncedDataProviderInterface
*/
private $notSyncedDataProvider;
/**
* @var OrderRepository
*/
private $orderRepository;
/**
* @var ResourceConnection
*/
private $resourceConnection;
/**
* @param OrderRepository $orderRepository
* @param ResourceConnection $resourceConnection
* @param Context $context
* @param string $mainTableName
* @param string $gridTableName
* @param string $orderIdField
* @param array $joins
* @param array $columns
* @param null $connectionName
* @param NotSyncedDataProviderInterface|null $notSyncedDataProvider
*/
public function __construct(
OrderRepository $orderRepository,
ResourceConnection $resourceConnection,
Context $context,
$mainTableName,
$gridTableName,
$orderIdField,
array $joins = [],
array $columns = [],
$connectionName = null,
NotSyncedDataProviderInterface $notSyncedDataProvider = null
) {
parent::__construct(
$context,
$mainTableName,
$gridTableName,
$orderIdField,
$joins,
$columns,
$connectionName,
$notSyncedDataProvider
);
$this->orderRepository = $orderRepository;
$this->resourceConnection = $resourceConnection;
$this->notSyncedDataProvider = $notSyncedDataProvider;
}
public function beforeRefreshBySchedule()
{
$this->notSyncedIds = $this->notSyncedDataProvider->getIds($this->mainTableName, $this->gridTableName);
}
public function afterRefreshBySchedule()
{
foreach ($this->notSyncedIds as $orderId) {
$postNLOrder = $this->orderRepository->getByOrderId($orderId);
if (!$postNLOrder) {
continue;
}
$shipAt = $postNLOrder->getShipAt();
$productCode = $postNLOrder->getProductCode();
$confirmed = $postNLOrder->getConfirmed();
$connection = $this->resourceConnection->getConnection();
$binds = [
'tig_postnl_ship_at' => $shipAt,
'tig_postnl_product_code' => $productCode,
'tig_postnl_confirmed' => $confirmed,
];
$where = [$connection->quoteIdentifier('entity_id') . '=?' => $orderId];
$connection->update('sales_order_grid', $binds, $where);
}
}
}
/**
*
* ..::..
* ..::::::::::::..
* ::'''''':''::'''''::
* ::.. ..: : ....::
* :::: ::: : : ::
* :::: ::: : ''' ::
* ::::..:::..::.....::
* ''::::::::::::''
* ''::''
*
*
* NOTICE OF LICENSE
*
* This source file is subject to the Creative Commons License.
* It is available through the world-wide-web at this URL:
* http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
* If you are unable to obtain it through the world-wide-web, please send an email
* to servicedesk@totalinternetgroup.nl so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this module to newer
* versions in the future. If you wish to customize this module for your
* needs please contact servicedesk@tig.nl for more information.
*
* @copyright Copyright (c) Total Internet Group B.V. https://tig.nl/copyright
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
*/
namespace TIG\PostNL\Plugin\Order;
use Magento\Framework\App\ResourceConnection;
use Magento\Framework\Model\ResourceModel\Db\Context;
use Magento\Sales\Model\ResourceModel\Grid;
use Magento\Sales\Model\ResourceModel\Provider\NotSyncedDataProviderInterface;
use TIG\PostNL\Model\OrderRepository;
class AsyncPlugin extends Grid
{
/**
* @var array
*/
private $notSyncedIds;
/**
* @var NotSyncedDataProviderInterface
*/
private $notSyncedDataProvider;
/**
* @var OrderRepository
*/
private $orderRepository;
/**
* @var ResourceConnection
*/
private $resourceConnection;
/**
* @param OrderRepository $orderRepository
* @param ResourceConnection $resourceConnection
* @param Context $context
* @param string $mainTableName
* @param string $gridTableName
* @param string $orderIdField
* @param array $joins
* @param array $columns
* @param null $connectionName
* @param NotSyncedDataProviderInterface|null $notSyncedDataProvider
*/
public function __construct(
OrderRepository $orderRepository,
ResourceConnection $resourceConnection,
Context $context,
$mainTableName,
$gridTableName,
$orderIdField,
array $joins = [],
array $columns = [],
$connectionName = null,
NotSyncedDataProviderInterface $notSyncedDataProvider = null
) {
parent::__construct(
$context,
$mainTableName,
$gridTableName,
$orderIdField,
$joins,
$columns,
$connectionName,
$notSyncedDataProvider
);
$this->orderRepository = $orderRepository;
$this->resourceConnection = $resourceConnection;
$this->notSyncedDataProvider = $notSyncedDataProvider;
}
public function beforeRefreshBySchedule()
{
$this->notSyncedIds = $this->notSyncedDataProvider->getIds($this->mainTableName, $this->gridTableName);
}
public function afterRefreshBySchedule()
{
foreach ($this->notSyncedIds as $orderId) {
$postNLOrder = $this->orderRepository->getByOrderId($orderId);
if (!$postNLOrder) {
continue;
}
$shipAt = $postNLOrder->getShipAt();
$productCode = $postNLOrder->getProductCode();
$confirmed = $postNLOrder->getConfirmed();
$connection = $this->resourceConnection->getConnection();
$binds = [
'tig_postnl_ship_at' => $shipAt,
'tig_postnl_product_code' => $productCode,
'tig_postnl_confirmed' => $confirmed,
];
$where = [$connection->quoteIdentifier('entity_id') . '=?' => $orderId];
$connection->update('sales_order_grid', $binds, $where);
}
}
}