Skip to content

Commit b42fab8

Browse files
#39169: Special Price To Date is wrongly validated on applySpecialPrice
- more targeted solution to cover only the question described in the issue
1 parent 3a45985 commit b42fab8

File tree

3 files changed

+11
-139
lines changed

3 files changed

+11
-139
lines changed

app/code/Magento/Catalog/Pricing/Price/SpecialPrice.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2015 Adobe
4+
* All Rights Reserved.
55
*/
66

77
namespace Magento\Catalog\Pricing\Price;
@@ -103,10 +103,16 @@ public function getSpecialToDate()
103103
*/
104104
public function isScopeDateInInterval()
105105
{
106+
$dateTo = $this->getSpecialToDate();
107+
if ($dateTo && date('H:i:s', strtotime($dateTo)) !== '00:00:00') {
108+
$dateToTimestamp = strtotime($dateTo);
109+
$dateTo = date('Y-m-d H:i:s', $dateToTimestamp - 86400);
110+
}
111+
106112
return $this->localeDate->isScopeDateInInterval(
107113
WebsiteInterface::ADMIN_CODE,
108114
$this->getSpecialFromDate(),
109-
$this->getSpecialToDate()
115+
$dateTo
110116
);
111117
}
112118

lib/internal/Magento/Framework/Stdlib/DateTime/Timezone.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,9 +274,9 @@ public function isScopeDateInInterval($scope, $dateFrom = null, $dateTo = null)
274274
$scopeTimeStamp = $this->scopeTimeStamp($scope);
275275
$fromTimeStamp = strtotime($dateFrom);
276276
$toTimeStamp = strtotime($dateTo);
277-
if ($dateTo && date('H:i:s', strtotime($dateTo)) === '00:00:00') {
277+
if ($dateTo) {
278278
// fix date YYYY-MM-DD 00:00:00 to YYYY-MM-DD 23:59:59
279-
$toTimeStamp += 86399;
279+
$toTimeStamp += 86400;
280280
}
281281

282282
return !(!$this->_dateTime->isEmptyDate($dateFrom) && $scopeTimeStamp < $fromTimeStamp ||

lib/internal/Magento/Framework/Stdlib/Test/Unit/DateTime/TimezoneScopeTest.php

Lines changed: 0 additions & 134 deletions
This file was deleted.

0 commit comments

Comments
 (0)