|
1
|
|
|
<?php |
|
2
|
|
|
declare(strict_types=1); |
|
3
|
|
|
/** |
|
4
|
|
|
*/ |
|
5
|
|
|
|
|
6
|
|
|
namespace CommerceLeague\ActiveCampaign\Helper; |
|
7
|
|
|
|
|
8
|
|
|
use Magento\Framework\App\Helper\AbstractHelper; |
|
9
|
|
|
use Magento\Framework\App\Helper\Context; |
|
10
|
|
|
use Magento\Quote\Model\ResourceModel\Quote\CollectionFactory as QuoteCollectionFactory; |
|
|
|
|
|
|
11
|
|
|
use Magento\Quote\Model\ResourceModel\Quote\Collection as QuoteCollection; |
|
12
|
|
|
use CommerceLeague\ActiveCampaign\Helper\Config as ConfigHelper; |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* Class AbandonedCart |
|
16
|
|
|
*/ |
|
17
|
|
|
class AbandonedCart extends AbstractHelper |
|
18
|
|
|
{ |
|
19
|
|
|
/** |
|
20
|
|
|
* @var QuoteCollectionFactory |
|
21
|
|
|
*/ |
|
22
|
|
|
private $quoteCollectionFactory; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* @var ConfigHelper |
|
26
|
|
|
*/ |
|
27
|
|
|
private $configHelper; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* @param Context $context |
|
31
|
|
|
* @param QuoteCollectionFactory $quoteCollectionFactory |
|
32
|
|
|
* @param Config $configHelper |
|
33
|
|
|
*/ |
|
34
|
|
|
public function __construct( |
|
35
|
|
|
Context $context, |
|
36
|
|
|
QuoteCollectionFactory $quoteCollectionFactory, |
|
37
|
|
|
ConfigHelper $configHelper |
|
38
|
|
|
) { |
|
39
|
|
|
$this->quoteCollectionFactory = $quoteCollectionFactory; |
|
40
|
|
|
$this->configHelper = $configHelper; |
|
41
|
|
|
parent::__construct($context); |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* @return QuoteCollection |
|
46
|
|
|
* @throws \Exception |
|
47
|
|
|
*/ |
|
48
|
|
|
public function getExportCollection(): QuoteCollection |
|
49
|
|
|
{ |
|
50
|
|
|
/** @var QuoteCollection $quoteCollection */ |
|
51
|
|
|
$quoteCollection = $this->quoteCollectionFactory->create(); |
|
52
|
|
|
|
|
53
|
|
|
$quoteCollection->addFieldToFilter( |
|
54
|
|
|
'items_count', |
|
55
|
|
|
['neq' => '0'] |
|
56
|
|
|
)->addFieldToFilter( |
|
57
|
|
|
'main_table.is_active', |
|
58
|
|
|
'1' |
|
59
|
|
|
)->addFieldToFilter( |
|
60
|
|
|
'main_table.customer_id', |
|
61
|
|
|
['neq' => null] |
|
62
|
|
|
); |
|
63
|
|
|
|
|
64
|
|
|
$minutes = (int)$this->configHelper->getAbandonedCartExportAfter(); |
|
65
|
|
|
|
|
66
|
|
|
$maxUpdatedAtTime = new \DateTime('now', new \DateTimeZone('UTC')); |
|
67
|
|
|
$interval = new \DateInterval(sprintf('PT%sM', $minutes)); |
|
68
|
|
|
$maxUpdatedAtTime->sub($interval); |
|
69
|
|
|
|
|
70
|
|
|
$quoteCollection->addFieldToFilter( |
|
71
|
|
|
'main_table.updated_at', |
|
72
|
|
|
['lteq' => $maxUpdatedAtTime->format('Y-m-d H:i:s')] |
|
73
|
|
|
); |
|
74
|
|
|
|
|
75
|
|
|
$quoteCollection->getSelect()->joinLeft( |
|
76
|
|
|
$quoteCollection->getSelect()->getConnection()->getTableName('activecampaign_abandoned'), |
|
|
|
|
|
|
77
|
|
|
'main_table.entity_id = activecampaign_abandoned.quote_id' |
|
78
|
|
|
); |
|
79
|
|
|
|
|
80
|
|
|
$quoteCollection->addFieldToFilter( |
|
81
|
|
|
'activecampaign_abandoned.activecampaign_id', |
|
82
|
|
|
['null' => true] |
|
83
|
|
|
); |
|
84
|
|
|
|
|
85
|
|
|
return $quoteCollection; |
|
86
|
|
|
} |
|
87
|
|
|
} |
|
88
|
|
|
|
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