Skip to content

Commit 1b7b6f8

Browse files
committed
MC-18954: Nightly build jobs were failing lately after un-skipping tests in MC-5777
1 parent 604c2cf commit 1b7b6f8

File tree

1 file changed

+10
-28
lines changed

1 file changed

+10
-28
lines changed

app/code/Magento/CatalogRule/Model/Indexer/ReindexRuleProduct.php

Lines changed: 10 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,8 @@
99
use Magento\CatalogRule\Model\Indexer\IndexerTableSwapperInterface as TableSwapper;
1010
use Magento\Catalog\Model\ResourceModel\Indexer\ActiveTableSwitcher;
1111
use Magento\CatalogRule\Model\Rule;
12-
use Magento\Framework\App\Config\ScopeConfigInterface;
1312
use Magento\Framework\App\ResourceConnection;
14-
use Magento\Framework\Stdlib\DateTime\TimezoneInterface;
15-
use Magento\Store\Model\ScopeInterface;
13+
use Magento\Framework\Stdlib\DateTime\Timezone\LocalizedDateToUtcConverterInterface;
1614

1715
/**
1816
* Reindex rule relations with products.
@@ -35,34 +33,26 @@ class ReindexRuleProduct
3533
private $tableSwapper;
3634

3735
/**
38-
* @var ScopeConfigInterface
36+
* @var LocalizedDateToUtcConverterInterface
3937
*/
40-
private $scopeConfig;
41-
42-
/**
43-
* @var TimezoneInterface
44-
*/
45-
private $localeDate;
38+
private $dateToUtcConverter;
4639

4740
/**
4841
* @param ResourceConnection $resource
4942
* @param ActiveTableSwitcher $activeTableSwitcher
5043
* @param TableSwapper $tableSwapper
51-
* @param ScopeConfigInterface $scopeConfig
52-
* @param TimezoneInterface $localeDate
44+
* @param LocalizedDateToUtcConverterInterface $dateToUtcConverter
5345
*/
5446
public function __construct(
5547
ResourceConnection $resource,
5648
ActiveTableSwitcher $activeTableSwitcher,
5749
TableSwapper $tableSwapper,
58-
ScopeConfigInterface $scopeConfig,
59-
TimezoneInterface $localeDate
50+
LocalizedDateToUtcConverterInterface $dateToUtcConverter
6051
) {
6152
$this->resource = $resource;
6253
$this->activeTableSwitcher = $activeTableSwitcher;
6354
$this->tableSwapper = $tableSwapper;
64-
$this->scopeConfig = $scopeConfig;
65-
$this->localeDate = $localeDate;
55+
$this->dateToUtcConverter = $dateToUtcConverter;
6656
}
6757

6858
/**
@@ -75,11 +65,8 @@ public function __construct(
7565
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
7666
* @SuppressWarnings(PHPMD.NPathComplexity)
7767
*/
78-
public function execute(
79-
Rule $rule,
80-
$batchCount,
81-
$useAdditionalTable = false
82-
) {
68+
public function execute(Rule $rule, $batchCount, $useAdditionalTable = false)
69+
{
8370
if (!$rule->getIsActive() || empty($rule->getWebsiteIds())) {
8471
return false;
8572
}
@@ -109,20 +96,15 @@ public function execute(
10996
$actionStop = $rule->getStopRulesProcessing();
11097

11198
$rows = [];
112-
11399
foreach ($productIds as $productId => $validationByWebsite) {
114100
foreach ($websiteIds as $websiteId) {
115101
if (empty($validationByWebsite[$websiteId])) {
116102
continue;
117103
}
118104

119-
$scopeTzPath = $this->localeDate->getDefaultTimezonePath();
120-
$scopeTz = new \DateTimeZone(
121-
$this->scopeConfig->getValue($scopeTzPath, ScopeInterface::SCOPE_WEBSITE, $websiteId)
122-
);
123-
$fromTime = (new \DateTime($rule->getFromDate(), $scopeTz))->getTimestamp();
105+
$fromTime = strtotime($this->dateToUtcConverter->convertLocalizedDateToUtc($rule->getFromDate()));
124106
$toTime = $rule->getToDate()
125-
? (new \DateTime($rule->getToDate(), $scopeTz))->getTimestamp() + IndexBuilder::SECONDS_IN_DAY - 1
107+
? strtotime($this->dateToUtcConverter->convertLocalizedDateToUtc($rule->getToDate()))
126108
: 0;
127109

128110
foreach ($customerGroupIds as $customerGroupId) {

0 commit comments

Comments
 (0)