6
6
7
7
namespace Magento \CatalogRule \Model \Indexer ;
8
8
9
- use DateTime ;
10
9
use Magento \Catalog \Model \Product ;
11
10
use Magento \CatalogRule \Model \ResourceModel \Rule \Collection as RuleCollection ;
12
11
use Magento \CatalogRule \Model \ResourceModel \Rule \CollectionFactory as RuleCollectionFactory ;
15
14
use Magento \Framework \Pricing \PriceCurrencyInterface ;
16
15
use Magento \CatalogRule \Model \Indexer \IndexBuilder \ProductLoader ;
17
16
use Magento \CatalogRule \Model \Indexer \IndexerTableSwapperInterface as TableSwapper ;
18
- use Magento \Framework \Stdlib \DateTime \TimezoneInterface ;
19
- use Magento \Store \Model \ScopeInterface ;
20
17
21
18
/**
22
19
* Catalog rule index builder
@@ -153,11 +150,6 @@ class IndexBuilder
153
150
*/
154
151
private $ productLoader ;
155
152
156
- /**
157
- * @var TimezoneInterface|mixed
158
- */
159
- private $ localeDate ;
160
-
161
153
/**
162
154
* @param RuleCollectionFactory $ruleCollectionFactory
163
155
* @param PriceCurrencyInterface $priceCurrency
@@ -178,7 +170,6 @@ class IndexBuilder
178
170
* @param \Magento\Catalog\Model\ResourceModel\Indexer\ActiveTableSwitcher|null $activeTableSwitcher
179
171
* @param ProductLoader|null $productLoader
180
172
* @param TableSwapper|null $tableSwapper
181
- * @param TimezoneInterface|null $localeDate
182
173
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
183
174
*/
184
175
public function __construct (
@@ -200,8 +191,7 @@ public function __construct(
200
191
RuleProductPricesPersistor $ pricesPersistor = null ,
201
192
\Magento \Catalog \Model \ResourceModel \Indexer \ActiveTableSwitcher $ activeTableSwitcher = null ,
202
193
ProductLoader $ productLoader = null ,
203
- TableSwapper $ tableSwapper = null ,
204
- ?TimezoneInterface $ localeDate = null
194
+ TableSwapper $ tableSwapper = null
205
195
) {
206
196
$ this ->resource = $ resource ;
207
197
$ this ->connection = $ resource ->getConnection ();
@@ -241,8 +231,6 @@ public function __construct(
241
231
);
242
232
$ this ->tableSwapper = $ tableSwapper ??
243
233
ObjectManager::getInstance ()->get (TableSwapper::class);
244
- $ this ->localeDate = $ localeDate ??
245
- ObjectManager::getInstance ()->get (TimezoneInterface::class);
246
234
}
247
235
248
236
/**
@@ -393,7 +381,6 @@ protected function cleanByIds($productIds)
393
381
* @param Rule $rule
394
382
* @param int $productEntityId
395
383
* @param array $websiteIds
396
- *
397
384
* @return void
398
385
* @throws \Exception
399
386
* @deprecated
@@ -412,23 +399,16 @@ private function assignProductToRule(Rule $rule, int $productEntityId, array $we
412
399
);
413
400
414
401
$ customerGroupIds = $ rule ->getCustomerGroupIds ();
402
+ $ fromTime = strtotime ($ rule ->getFromDate ());
403
+ $ toTime = strtotime ($ rule ->getToDate ());
404
+ $ toTime = $ toTime ? $ toTime + self ::SECONDS_IN_DAY - 1 : 0 ;
415
405
$ sortOrder = (int )$ rule ->getSortOrder ();
416
406
$ actionOperator = $ rule ->getSimpleAction ();
417
407
$ actionAmount = $ rule ->getDiscountAmount ();
418
408
$ actionStop = $ rule ->getStopRulesProcessing ();
419
409
420
410
$ rows = [];
421
411
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
-
432
412
foreach ($ customerGroupIds as $ customerGroupId ) {
433
413
$ rows [] = [
434
414
'rule_id ' => $ ruleId ,
0 commit comments