Skip to content

Tierprice discount not calculated correctly if has specialprice. #18652

@Hoszi

Description

@Hoszi

Preconditions (*)

  1. Install the newest version 2.2.6

Steps to reproduce (*)

  1. Add new product with price $18.42
  2. Add special price $14
  3. Add tier price with qty=2, type = "Discount" and value = "%12"
  4. Add tier price with qty=300, type = "Discount" and value = "%25"
  5. Add tier price with qty=1000, type = "Discount" and value = "%50"
  6. Save the product

Expected result (*)

  1. The tierprice discount calculated by specialprice and show all the tierprice

Actual result (*)

  1. The price and the "Discount" value on frontend for qty=2 is not visible
  2. The tierprice percent for qty=300 is 1% instead of 25% on frontend

Possible Solution

In:
\Magento\Catalog\Model\Product\Attribute\Backend\Tierprice.php
change modifyPriceData function like this:

protected function modifyPriceData($object, $data)
{
    /** @var \Magento\Catalog\Model\Product $object */
    $data = parent::modifyPriceData($object, $data);
    $price = $object->getPrice();

    // ADD FROM HERE
    $specialprice = $object->getSpecialPrice();
    $specialPriceFromDate = $object->getSpecialFromDate();
    $specialPriceToDate = $object->getSpecialToDate();
    $today = time();

    if ($specialprice && ($object->getPrice() > $object->getFinalPrice())){
        if ($today >= strtotime($specialPriceFromDate) && $today <= strtotime($specialPriceToDate) ||
            $today >= strtotime($specialPriceFromDate) && is_null($specialPriceToDate)) {
            $price = $specialprice;
        }
    }
    // TO HERE

    foreach ($data as $key => $tierPrice) {
        $percentageValue = $this->getPercentage($tierPrice);
        if ($percentageValue) {
            $data[$key]['price'] = $price * (1 - $percentageValue / 100);
            $data[$key]['website_price'] = $data[$key]['price'];
        }
    }
    return $data;
}

Metadata

Metadata

Labels

Component: UiFixed in 2.2.xThe issue has been fixed in 2.2 release lineFixed in 2.3.xThe issue has been fixed in 2.3 release lineIssue: Clear DescriptionGate 2 Passed. Manual verification of the issue description passedIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedIssue: Format is validGate 1 Passed. Automatic verification of issue format passedIssue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentReproduced on 2.3.xThe issue has been reproduced on latest 2.3 release

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions