Skip to content

Commit 1fa73b7

Browse files
author
Oleksandr Dubovyk
committed
MC-20212: [On premise] Data loss due to core cron job called sales_clean_quotes
- small refactor
1 parent 28f00aa commit 1fa73b7

File tree

2 files changed

+11
-34
lines changed

2 files changed

+11
-34
lines changed

app/code/Magento/Sales/Cron/CleanExpiredQuotes.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
namespace Magento\Sales\Cron;
77

88
use Magento\Quote\Model\ResourceModel\Quote\Collection;
9-
use Magento\Sales\Helper\ExpiredQuotesCollection;
9+
use Magento\Sales\Model\ResourceModel\ExpiredQuotesCollection;
1010
use Magento\Store\Model\StoreManagerInterface;
1111

1212
/**

app/code/Magento/Sales/Helper/ExpiredQuotesCollection.php renamed to app/code/Magento/Sales/Model/ResourceModel/Collection/ExpiredQuotesCollection.php

Lines changed: 10 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,20 @@
1616
*/
1717
class ExpiredQuotesCollection
1818
{
19-
const SECONDS_IN_DAY = 86400;
20-
const QUOTE_LIFETIME = 'checkout/cart/delete_quote_after';
19+
/**
20+
* @var int
21+
*/
22+
private $secondsInDay = 86400;
2123

2224
/**
23-
* @var CollectionFactory
25+
* @var string
2426
*/
25-
private $quoteCollectionFactory;
27+
private $quoteLifetime = 'checkout/cart/delete_quote_after';
2628

2729
/**
28-
* @var array
30+
* @var CollectionFactory
2931
*/
30-
private $expireQuotesFilterFields = [];
32+
private $quoteCollectionFactory;
3133

3234
/**
3335
* @var ScopeConfigInterface
@@ -58,42 +60,17 @@ public function __construct(
5860
public function getExpiredQuotes(StoreInterface $store)
5961
{
6062
$lifetime = $this->config->getValue(
61-
self::QUOTE_LIFETIME,
63+
$this->quoteLifetime,
6264
ScopeInterface::SCOPE_STORE,
6365
$store->getCode()
6466
);
65-
$lifetime *= self::SECONDS_IN_DAY;
67+
$lifetime *= $this->secondsInDay;
6668

6769
/** @var $quotes Collection */
6870
$quotes = $this->quoteCollectionFactory->create();
6971
$quotes->addFieldToFilter('store_id', $store->getId());
7072
$quotes->addFieldToFilter('updated_at', ['to' => date("Y-m-d", time() - $lifetime)]);
7173

72-
foreach ($this->getExpireQuotesAdditionalFilterFields() as $field => $condition) {
73-
$quotes->addFieldToFilter($field, $condition);
74-
}
75-
7674
return $quotes;
7775
}
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-
}
9976
}

0 commit comments

Comments
 (0)