|
16 | 16 | */
|
17 | 17 | class ExpiredQuotesCollection
|
18 | 18 | {
|
19 |
| - const SECONDS_IN_DAY = 86400; |
20 |
| - const QUOTE_LIFETIME = 'checkout/cart/delete_quote_after'; |
| 19 | + /** |
| 20 | + * @var int |
| 21 | + */ |
| 22 | + private $secondsInDay = 86400; |
21 | 23 |
|
22 | 24 | /**
|
23 |
| - * @var CollectionFactory |
| 25 | + * @var string |
24 | 26 | */
|
25 |
| - private $quoteCollectionFactory; |
| 27 | + private $quoteLifetime = 'checkout/cart/delete_quote_after'; |
26 | 28 |
|
27 | 29 | /**
|
28 |
| - * @var array |
| 30 | + * @var CollectionFactory |
29 | 31 | */
|
30 |
| - private $expireQuotesFilterFields = []; |
| 32 | + private $quoteCollectionFactory; |
31 | 33 |
|
32 | 34 | /**
|
33 | 35 | * @var ScopeConfigInterface
|
@@ -58,42 +60,17 @@ public function __construct(
|
58 | 60 | public function getExpiredQuotes(StoreInterface $store)
|
59 | 61 | {
|
60 | 62 | $lifetime = $this->config->getValue(
|
61 |
| - self::QUOTE_LIFETIME, |
| 63 | + $this->quoteLifetime, |
62 | 64 | ScopeInterface::SCOPE_STORE,
|
63 | 65 | $store->getCode()
|
64 | 66 | );
|
65 |
| - $lifetime *= self::SECONDS_IN_DAY; |
| 67 | + $lifetime *= $this->secondsInDay; |
66 | 68 |
|
67 | 69 | /** @var $quotes Collection */
|
68 | 70 | $quotes = $this->quoteCollectionFactory->create();
|
69 | 71 | $quotes->addFieldToFilter('store_id', $store->getId());
|
70 | 72 | $quotes->addFieldToFilter('updated_at', ['to' => date("Y-m-d", time() - $lifetime)]);
|
71 | 73 |
|
72 |
| - foreach ($this->getExpireQuotesAdditionalFilterFields() as $field => $condition) { |
73 |
| - $quotes->addFieldToFilter($field, $condition); |
74 |
| - } |
75 |
| - |
76 | 74 | return $quotes;
|
77 | 75 | }
|
78 |
| - |
79 |
| - /** |
80 |
| - * Retrieve expire quotes additional fields to filter |
81 |
| - * |
82 |
| - * @return array |
83 |
| - */ |
84 |
| - private function getExpireQuotesAdditionalFilterFields() |
85 |
| - { |
86 |
| - return $this->expireQuotesFilterFields; |
87 |
| - } |
88 |
| - |
89 |
| - /** |
90 |
| - * Set expire quotes additional fields to filter |
91 |
| - * |
92 |
| - * @param array $fields |
93 |
| - * @return void |
94 |
| - */ |
95 |
| - public function setExpireQuotesAdditionalFilterFields(array $fields) |
96 |
| - { |
97 |
| - $this->expireQuotesFilterFields = $fields; |
98 |
| - } |
99 | 76 | }
|
0 commit comments