1
|
|
|
<?php |
2
|
|
|
declare(strict_types=1); |
3
|
|
|
/** |
4
|
|
|
*/ |
5
|
|
|
|
6
|
|
|
namespace CommerceLeague\ActiveCampaign\Console\Command; |
7
|
|
|
|
8
|
|
|
use CommerceLeague\ActiveCampaign\MessageQueue\Topics; |
9
|
|
|
use Magento\Framework\Console\Cli; |
10
|
|
|
use Magento\Framework\MessageQueue\PublisherInterface; |
11
|
|
|
use Symfony\Component\Console\Helper\ProgressBarFactory; |
|
|
|
|
12
|
|
|
use Magento\Sales\Model\ResourceModel\Order\CollectionFactory as MagentoOrderCollectionFactory; |
13
|
|
|
use Magento\Sales\Model\ResourceModel\Order\Collection as MagentoOrderCollection; |
14
|
|
|
use Magento\Sales\Model\Order as MagentoOrder; |
15
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
16
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
17
|
|
|
|
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Class ExportOrderCommand |
21
|
|
|
*/ |
22
|
|
|
class ExportOrderCommand extends AbstractExportCommand |
23
|
|
|
{ |
24
|
|
|
private const NAME = 'activecampaign:export:order'; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* @var MagentoOrderCollectionFactory |
28
|
|
|
*/ |
29
|
|
|
private $magentoOrderCollectionFactory; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @param MagentoOrderCollectionFactory $magentoOrderCollectionFactory |
33
|
|
|
* @param PublisherInterface $publisher |
34
|
|
|
* @param ProgressBarFactory $progressBarFactory |
35
|
|
|
*/ |
36
|
|
|
public function __construct( |
37
|
|
|
MagentoOrderCollectionFactory $magentoOrderCollectionFactory, |
38
|
|
|
PublisherInterface $publisher, |
39
|
|
|
ProgressBarFactory $progressBarFactory |
40
|
|
|
) { |
41
|
|
|
$this->magentoOrderCollectionFactory = $magentoOrderCollectionFactory; |
42
|
|
|
parent::__construct($progressBarFactory, $publisher); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @inheritDoc |
47
|
|
|
*/ |
48
|
|
|
protected function configure() |
49
|
|
|
{ |
50
|
|
|
$this->setName(self::NAME); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* @inheritDoc |
55
|
|
|
*/ |
56
|
|
|
protected function execute(InputInterface $input, OutputInterface $output) |
57
|
|
|
{ |
58
|
|
|
$magentoOrderIds = $this->getMagentoOrderIds(); |
59
|
|
|
|
60
|
|
|
$progressBar = $this->createProgressBar( |
61
|
|
|
$output, |
62
|
|
|
count($magentoOrderIds), |
63
|
|
|
'Export Magento Order(s)' |
64
|
|
|
); |
65
|
|
|
|
66
|
|
|
foreach ($magentoOrderIds as $magentoOrderId) { |
67
|
|
|
$this->publisher->publish( |
68
|
|
|
Topics::SALES_ORDER_EXPORT, |
69
|
|
|
json_encode(['magento_order_id' => $magentoOrderId]) |
|
|
|
|
70
|
|
|
); |
71
|
|
|
|
72
|
|
|
$progressBar->advance(); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
$output->writeln(''); |
76
|
|
|
$output->writeln(sprintf( |
77
|
|
|
'<info>Exported %s order(s)</info>', |
78
|
|
|
(count($magentoOrderIds))) |
79
|
|
|
); |
80
|
|
|
|
81
|
|
|
return Cli::RETURN_SUCCESS; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* @return array |
86
|
|
|
*/ |
87
|
|
|
private function getMagentoOrderIds(): array |
88
|
|
|
{ |
89
|
|
|
/** @var MagentoOrderCollection $magentoOrderCollection */ |
90
|
|
|
$magentoOrderCollection = $this->magentoOrderCollectionFactory->create(); |
91
|
|
|
$magentoOrderCollection->addFieldToFilter(MagentoOrder::STATUS, MagentoOrder::STATE_COMPLETE); |
92
|
|
|
$magentoOrderCollection->addFieldToFilter(MagentoOrder::CUSTOMER_IS_GUEST, false); |
|
|
|
|
93
|
|
|
|
94
|
|
|
return $magentoOrderCollection->getAllIds(); |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
|
98
|
|
|
|
99
|
|
|
} |
100
|
|
|
|
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