Skip to content

Commit c7def24

Browse files
committed
Revert "WIP Scheduled price rule time zone correction"
This reverts commit 5972daa.
1 parent 0e68e70 commit c7def24

File tree

1 file changed

+4
-24
lines changed

1 file changed

+4
-24
lines changed

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

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
namespace Magento\CatalogRule\Model\Indexer;
88

9-
use DateTime;
109
use Magento\Catalog\Model\Product;
1110
use Magento\CatalogRule\Model\ResourceModel\Rule\Collection as RuleCollection;
1211
use Magento\CatalogRule\Model\ResourceModel\Rule\CollectionFactory as RuleCollectionFactory;
@@ -15,8 +14,6 @@
1514
use Magento\Framework\Pricing\PriceCurrencyInterface;
1615
use Magento\CatalogRule\Model\Indexer\IndexBuilder\ProductLoader;
1716
use Magento\CatalogRule\Model\Indexer\IndexerTableSwapperInterface as TableSwapper;
18-
use Magento\Framework\Stdlib\DateTime\TimezoneInterface;
19-
use Magento\Store\Model\ScopeInterface;
2017

2118
/**
2219
* Catalog rule index builder
@@ -153,11 +150,6 @@ class IndexBuilder
153150
*/
154151
private $productLoader;
155152

156-
/**
157-
* @var TimezoneInterface|mixed
158-
*/
159-
private $localeDate;
160-
161153
/**
162154
* @param RuleCollectionFactory $ruleCollectionFactory
163155
* @param PriceCurrencyInterface $priceCurrency
@@ -178,7 +170,6 @@ class IndexBuilder
178170
* @param \Magento\Catalog\Model\ResourceModel\Indexer\ActiveTableSwitcher|null $activeTableSwitcher
179171
* @param ProductLoader|null $productLoader
180172
* @param TableSwapper|null $tableSwapper
181-
* @param TimezoneInterface|null $localeDate
182173
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
183174
*/
184175
public function __construct(
@@ -200,8 +191,7 @@ public function __construct(
200191
RuleProductPricesPersistor $pricesPersistor = null,
201192
\Magento\Catalog\Model\ResourceModel\Indexer\ActiveTableSwitcher $activeTableSwitcher = null,
202193
ProductLoader $productLoader = null,
203-
TableSwapper $tableSwapper = null,
204-
?TimezoneInterface $localeDate = null
194+
TableSwapper $tableSwapper = null
205195
) {
206196
$this->resource = $resource;
207197
$this->connection = $resource->getConnection();
@@ -241,8 +231,6 @@ public function __construct(
241231
);
242232
$this->tableSwapper = $tableSwapper ??
243233
ObjectManager::getInstance()->get(TableSwapper::class);
244-
$this->localeDate = $localeDate ??
245-
ObjectManager::getInstance()->get(TimezoneInterface::class);
246234
}
247235

248236
/**
@@ -393,7 +381,6 @@ protected function cleanByIds($productIds)
393381
* @param Rule $rule
394382
* @param int $productEntityId
395383
* @param array $websiteIds
396-
*
397384
* @return void
398385
* @throws \Exception
399386
* @deprecated
@@ -412,23 +399,16 @@ private function assignProductToRule(Rule $rule, int $productEntityId, array $we
412399
);
413400

414401
$customerGroupIds = $rule->getCustomerGroupIds();
402+
$fromTime = strtotime($rule->getFromDate());
403+
$toTime = strtotime($rule->getToDate());
404+
$toTime = $toTime ? $toTime + self::SECONDS_IN_DAY - 1 : 0;
415405
$sortOrder = (int)$rule->getSortOrder();
416406
$actionOperator = $rule->getSimpleAction();
417407
$actionAmount = $rule->getDiscountAmount();
418408
$actionStop = $rule->getStopRulesProcessing();
419409

420410
$rows = [];
421411
foreach ($websiteIds as $websiteId) {
422-
$scopeTz = new \DateTimeZone(
423-
$this->localeDate->getConfigTimezone(ScopeInterface::SCOPE_WEBSITE, $websiteId)
424-
);
425-
$fromTime = $rule->getFromDate()
426-
? (new DateTime($rule->getFromDate(), $scopeTz))->getTimestamp()
427-
: 0;
428-
$toTime = $rule->getToDate()
429-
? (new DateTime($rule->getToDate(), $scopeTz))->getTimestamp() + IndexBuilder::SECONDS_IN_DAY - 1
430-
: 0;
431-
432412
foreach ($customerGroupIds as $customerGroupId) {
433413
$rows[] = [
434414
'rule_id' => $ruleId,

0 commit comments

Comments
 (0)