Skip to content

Commit 8ace126

Browse files
#39169: Special Price To Date is wrongly validated on applySpecialPrice
- cover additional isScopeDateInInterval method usage for special price interval checking
1 parent b42fab8 commit 8ace126

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

app/code/Magento/Bundle/Model/Product/Price.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,12 @@ public function calculateSpecialPrice(
629629
$store = null
630630
) {
631631
if ($specialPrice !== null && $specialPrice != false) {
632+
633+
if ($specialPriceTo && date('H:i:s', strtotime($specialPriceTo)) !== '00:00:00') {
634+
$dateToTimestamp = strtotime($specialPriceTo);
635+
$specialPriceTo = date('Y-m-d H:i:s', $dateToTimestamp - 86400);
636+
}
637+
632638
if ($this->_localeDate->isScopeDateInInterval($store, $specialPriceFrom, $specialPriceTo)) {
633639
$specialPrice = $finalPrice * ($specialPrice / 100);
634640
$finalPrice = min($finalPrice, $specialPrice);

app/code/Magento/Catalog/Model/Product/Type/Price.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,11 @@ public function calculatePrice(
602602

603603
$finalPrice = $basePrice;
604604

605+
if ($specialPriceTo && date('H:i:s', strtotime($specialPriceTo)) !== '00:00:00') {
606+
$dateToTimestamp = strtotime($specialPriceTo);
607+
$specialPriceTo = date('Y-m-d H:i:s', $dateToTimestamp - 86400);
608+
}
609+
605610
$finalPrice = $this->calculateSpecialPrice(
606611
$finalPrice,
607612
$specialPrice,
@@ -642,6 +647,12 @@ public function calculateSpecialPrice(
642647
$store = null
643648
) {
644649
if ($specialPrice !== null && $specialPrice != false) {
650+
651+
if ($specialPriceTo && date('H:i:s', strtotime($specialPriceTo)) !== '00:00:00') {
652+
$dateToTimestamp = strtotime($specialPriceTo);
653+
$specialPriceTo = date('Y-m-d H:i:s', $dateToTimestamp - 86400);
654+
}
655+
645656
if ($this->_localeDate->isScopeDateInInterval($store, $specialPriceFrom, $specialPriceTo)) {
646657
$finalPrice = min($finalPrice, (float) $specialPrice);
647658
}

0 commit comments

Comments
 (0)