1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Copyright © Wirecard Brasil. All rights reserved. |
4
|
|
|
* |
5
|
|
|
* @author Bruno Elisei <[email protected]> |
6
|
|
|
* See COPYING.txt for license details. |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
namespace Moip\Magento2\Controller\Adminhtml\Order; |
10
|
|
|
|
11
|
|
|
use Magento\Backend\App\Action\Context; |
|
|
|
|
12
|
|
|
use Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection; |
|
|
|
|
13
|
|
|
use Magento\Sales\Api\OrderManagementInterface; |
|
|
|
|
14
|
|
|
use Magento\Sales\Model\Order; |
|
|
|
|
15
|
|
|
use Magento\Sales\Model\ResourceModel\Order\CollectionFactory; |
|
|
|
|
16
|
|
|
use Magento\Ui\Component\MassAction\Filter; |
|
|
|
|
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Class MassDelete. |
20
|
|
|
*/ |
21
|
|
|
class MassUpdate extends \Magento\Sales\Controller\Adminhtml\Order\AbstractMassAction |
|
|
|
|
22
|
|
|
{ |
23
|
|
|
/* |
24
|
|
|
* @var Order Management |
25
|
|
|
*/ |
26
|
|
|
protected $orderManagement; |
27
|
|
|
|
28
|
|
|
/* |
29
|
|
|
* @param Context |
30
|
|
|
* @param Filter |
31
|
|
|
* @param CollectionFactory |
32
|
|
|
* @param OrderManagementInterface |
33
|
|
|
*/ |
34
|
|
|
public function __construct( |
35
|
|
|
Context $context, |
36
|
|
|
Filter $filter, |
37
|
|
|
CollectionFactory $collectionFactory, |
38
|
|
|
OrderManagementInterface $orderManagement, |
39
|
|
|
Order $order |
40
|
|
|
) { |
41
|
|
|
parent::__construct($context, $filter); |
42
|
|
|
$this->collectionFactory = $collectionFactory; |
|
|
|
|
43
|
|
|
$this->orderManagement = $orderManagement; |
44
|
|
|
$this->order = $order; |
|
|
|
|
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/* |
48
|
|
|
* Mass Action |
49
|
|
|
* |
50
|
|
|
* @param collection |
51
|
|
|
* |
52
|
|
|
* @return Url |
|
|
|
|
53
|
|
|
*/ |
54
|
|
|
protected function massAction(AbstractCollection $collection) |
55
|
|
|
{ |
56
|
|
|
$countUpdate = 0; |
57
|
|
|
$countNotUpdate = 0; |
58
|
|
|
|
59
|
|
|
foreach ($collection->getItems() as $order) { |
60
|
|
|
if (!$order->getEntityId()) { |
61
|
|
|
continue; |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
$loadedOrder = $this->order->load($order->getEntityId()); |
65
|
|
|
|
66
|
|
|
if ($loadedOrder->canFetchPaymentReviewUpdate()) { |
67
|
|
|
$payment = $loadedOrder->getPayment(); |
68
|
|
|
$transactionId = $payment->getLastTransId(); |
69
|
|
|
$method = $payment->getMethodInstance(); |
70
|
|
|
|
71
|
|
|
try { |
72
|
|
|
$method->fetchTransactionInfo($payment, $transactionId); |
73
|
|
|
$payment->getOrder()->save(); |
74
|
|
|
$state = $payment->getOrder()->getState(); |
75
|
|
|
if ($state === 'processing') { |
76
|
|
|
$countUpdate++; |
77
|
|
|
} |
78
|
|
|
$countNotUpdate++; |
79
|
|
|
} catch (\Exception $exc) { |
80
|
|
|
$countNotUpdate++; |
81
|
|
|
} |
82
|
|
|
} elseif (!$loadedOrder->canFetchPaymentReviewUpdate()) { |
83
|
|
|
$countNotUpdate++; |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
continue; |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
if ($countUpdate) { |
90
|
|
|
$this->messageManager->addSuccess(__('%1 payments have been updated.', $countUpdate)); |
|
|
|
|
91
|
|
|
} |
92
|
|
|
if ($countNotUpdate) { |
93
|
|
|
$this->messageManager->addWarning(__('%1 payments have not yet been updated.', $countNotUpdate)); |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
$resultRedirect = $this->resultRedirectFactory->create(); |
97
|
|
|
$resultRedirect->setPath($this->getComponentRefererUrl()); |
98
|
|
|
|
99
|
|
|
return $resultRedirect; |
100
|
|
|
} |
101
|
|
|
} |
102
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths