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\Quote\Collection as QuoteCollection; |
||||
11 | use CommerceLeague\ActiveCampaign\Model\ResourceModel\Quote\CollectionFactory as QuoteCollectionFactory; |
||||
0 ignored issues
–
show
|
|||||
12 | use Magento\Framework\MessageQueue\PublisherInterface; |
||||
13 | |||||
14 | /** |
||||
15 | * Class ExportOmittedAbandonedCarts |
||||
16 | */ |
||||
17 | class ExportOmittedAbandonedCarts implements CronInterface |
||||
18 | { |
||||
19 | /** |
||||
20 | * @var ConfigHelper |
||||
21 | */ |
||||
22 | private $configHelper; |
||||
23 | |||||
24 | /** |
||||
25 | * @var QuoteCollectionFactory |
||||
26 | */ |
||||
27 | private $quoteCollectionFactory; |
||||
28 | |||||
29 | /** |
||||
30 | * @var PublisherInterface |
||||
31 | */ |
||||
32 | private $publisher; |
||||
33 | |||||
34 | /** |
||||
35 | * @param ConfigHelper $configHelper |
||||
36 | * @param QuoteCollectionFactory $quoteCollectionFactory |
||||
37 | * @param PublisherInterface $publisher |
||||
38 | */ |
||||
39 | public function __construct( |
||||
40 | ConfigHelper $configHelper, |
||||
41 | QuoteCollectionFactory $quoteCollectionFactory, |
||||
42 | PublisherInterface $publisher |
||||
43 | ) { |
||||
44 | $this->configHelper = $configHelper; |
||||
45 | $this->quoteCollectionFactory = $quoteCollectionFactory; |
||||
46 | $this->publisher = $publisher; |
||||
47 | } |
||||
48 | |||||
49 | /** |
||||
50 | * @throws \Exception |
||||
51 | */ |
||||
52 | public function run(): void |
||||
53 | { |
||||
54 | if (!$this->configHelper->isEnabled() || !$this->configHelper->isAbandonedCartExportEnabled()) { |
||||
55 | return; |
||||
56 | } |
||||
57 | |||||
58 | $quoteIds = $this->getQuoteIds(); |
||||
59 | |||||
60 | foreach ($quoteIds as $quoteId) { |
||||
61 | $this->publisher->publish( |
||||
62 | Topics::QUOTE_ABANDONED_CART_EXPORT, |
||||
63 | json_encode(['quote_id' => $quoteId]) |
||||
0 ignored issues
–
show
json_encode(array('quote_id' => $quoteId)) of type string is incompatible with the type array|object expected by parameter $data of Magento\Framework\Messag...herInterface::publish() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
64 | ); |
||||
65 | } |
||||
66 | } |
||||
67 | |||||
68 | /** |
||||
69 | * @return array |
||||
70 | * @throws \Exception |
||||
71 | */ |
||||
72 | private function getQuoteIds(): array |
||||
73 | { |
||||
74 | /** @var QuoteCollection $quoteCollection */ |
||||
75 | $quoteCollection = $this->quoteCollectionFactory->create(); |
||||
76 | $quoteCollection->addAbandonedFilter(); |
||||
77 | $quoteCollection->addOmittedFilter(); |
||||
78 | |||||
79 | return $quoteCollection->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