Skip to content

Commit 52a989c

Browse files
authored
ENGCOM-3450: [Forwardport] Fixed tierprice discount not calculated correctly if has specialprice #19179
2 parents ee11eb6 + 0a12f2f commit 52a989c

File tree

1 file changed

+21
-0
lines changed
  • app/code/Magento/Catalog/Model/Product/Attribute/Backend

1 file changed

+21
-0
lines changed

app/code/Magento/Catalog/Model/Product/Attribute/Backend/Tierprice.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313

1414
use Magento\Catalog\Model\Attribute\ScopeOverriddenValue;
1515

16+
/**
17+
* Backend model for Tierprice attribute
18+
*/
1619
class Tierprice extends \Magento\Catalog\Model\Product\Attribute\Backend\GroupPrice\AbstractGroupPrice
1720
{
1821
/**
@@ -159,8 +162,22 @@ protected function validatePrice(array $priceRow)
159162
*/
160163
protected function modifyPriceData($object, $data)
161164
{
165+
/** @var \Magento\Catalog\Model\Product $object */
162166
$data = parent::modifyPriceData($object, $data);
163167
$price = $object->getPrice();
168+
169+
$specialPrice = $object->getSpecialPrice();
170+
$specialPriceFromDate = $object->getSpecialFromDate();
171+
$specialPriceToDate = $object->getSpecialToDate();
172+
$today = time();
173+
174+
if ($specialPrice && ($object->getPrice() > $object->getFinalPrice())) {
175+
if ($today >= strtotime($specialPriceFromDate) && $today <= strtotime($specialPriceToDate) ||
176+
$today >= strtotime($specialPriceFromDate) && $specialPriceToDate === null) {
177+
$price = $specialPrice;
178+
}
179+
}
180+
164181
foreach ($data as $key => $tierPrice) {
165182
$percentageValue = $this->getPercentage($tierPrice);
166183
if ($percentageValue) {
@@ -172,6 +189,10 @@ protected function modifyPriceData($object, $data)
172189
}
173190

174191
/**
192+
* Update Price values in DB
193+
*
194+
* Updates price values in DB from array comparing to old values. Returns bool if updated
195+
*
175196
* @param array $valuesToUpdate
176197
* @param array $oldValues
177198
* @return boolean

0 commit comments

Comments
 (0)