1
|
|
|
<?php |
2
|
|
|
declare(strict_types=1); |
3
|
|
|
/** |
4
|
|
|
*/ |
5
|
|
|
|
6
|
|
|
namespace CommerceLeague\ActiveCampaign\Cron; |
7
|
|
|
|
8
|
|
|
use CommerceLeague\ActiveCampaign\Helper\Config as ConfigHelper; |
9
|
|
|
use CommerceLeague\ActiveCampaign\MessageQueue\Topics; |
10
|
|
|
use CommerceLeague\ActiveCampaign\Model\ResourceModel\Order\Collection as OrderCollection; |
11
|
|
|
use CommerceLeague\ActiveCampaign\Model\ResourceModel\Order\CollectionFactory as OrderCollectionFactory; |
|
|
|
|
12
|
|
|
use Magento\Framework\MessageQueue\PublisherInterface; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Class ExportOmittedOrders |
16
|
|
|
*/ |
17
|
|
|
class ExportOmittedOrders implements CronInterface |
18
|
|
|
{ |
19
|
|
|
/** |
20
|
|
|
* @var ConfigHelper |
21
|
|
|
*/ |
22
|
|
|
private $configHelper; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* @var OrderCollectionFactory |
26
|
|
|
*/ |
27
|
|
|
private $orderCollectionFactory; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @var PublisherInterface |
31
|
|
|
*/ |
32
|
|
|
private $publisher; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @param ConfigHelper $configHelper |
36
|
|
|
* @param OrderCollectionFactory $orderCollectionFactory |
37
|
|
|
* @param PublisherInterface $publisher |
38
|
|
|
*/ |
39
|
|
|
public function __construct( |
40
|
|
|
ConfigHelper $configHelper, |
41
|
|
|
OrderCollectionFactory $orderCollectionFactory, |
42
|
|
|
PublisherInterface $publisher |
43
|
|
|
) { |
44
|
|
|
$this->configHelper = $configHelper; |
45
|
|
|
$this->orderCollectionFactory = $orderCollectionFactory; |
46
|
|
|
$this->publisher = $publisher; |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @inheritDoc |
52
|
|
|
*/ |
53
|
|
|
public function run(): void |
54
|
|
|
{ |
55
|
|
|
if (!$this->configHelper->isEnabled() || !$this->configHelper->isOrderExportEnabled()) { |
56
|
|
|
return; |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
$orderIds = $this->getOrderIds(); |
60
|
|
|
|
61
|
|
|
foreach ($orderIds as $orderId) { |
62
|
|
|
$this->publisher->publish( |
63
|
|
|
Topics::SALES_ORDER_EXPORT, |
64
|
|
|
json_encode(['magento_order_id' => $orderId]) |
|
|
|
|
65
|
|
|
); |
66
|
|
|
} |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* @return array |
71
|
|
|
*/ |
72
|
|
|
public function getOrderIds(): array |
73
|
|
|
{ |
74
|
|
|
/** @var OrderCollection $orderCollection */ |
75
|
|
|
$orderCollection = $this->orderCollectionFactory->create(); |
76
|
|
|
$orderCollection->addExcludeGuestFilter(); |
77
|
|
|
$orderCollection->addOmittedFilter(); |
78
|
|
|
|
79
|
|
|
return $orderCollection->getAllIds(); |
80
|
|
|
} |
81
|
|
|
} |
82
|
|
|
|
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