Skip to content

Commit d3fbc0c

Browse files
committed
Updated code for special price issue fix
1 parent 1636cd1 commit d3fbc0c

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

Helper/Entity/Product/PriceManager/ProductWithChildren.php

100644100755
Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,13 @@ protected function getMinMaxPrices(Product $product, $withTax, $subProducts, $cu
4949
/** @var Product $subProduct */
5050
foreach ($subProducts as $subProduct) {
5151
$specialPrice = $this->getSpecialPrice($subProduct, $currencyCode, $withTax, $subProducts);
52-
$price = $specialPrice[0] ?? $this->getTaxPrice($product, $subProduct->getFinalPrice(), $withTax);
52+
$tierPrice = $this->getTierPrice($subProduct, $currencyCode, $withTax);
53+
if (!empty($tierPrice[0]) && $specialPrice[0] > $tierPrice[0]){
54+
$minPrice = $tierPrice[0];
55+
} else {
56+
$minPrice = $specialPrice[0];
57+
}
58+
$price = $minPrice ?? $this->getTaxPrice($product, $subProduct->getFinalPrice(), $withTax);
5359
$basePrice = $this->getTaxPrice($product, $subProduct->getPrice(), $withTax);
5460
$min = min($min, $price);
5561
$original = min($original, $basePrice);
@@ -155,11 +161,17 @@ protected function setFinalGroupPrices($field, $currencyCode, $min, $max, $dashe
155161
/** @var Group $group */
156162
foreach ($this->groups as $group) {
157163
$groupId = (int) $group->getData('customer_group_id');
164+
$minPrice = $min;
158165
foreach ($subproducts as $subProduct) {
159166
$subProduct->setData('customer_group_id', $groupId);
160167
$subProduct->setData('website_id', $subProduct->getStore()->getWebsiteId());
168+
$specialPrice = $this->getSpecialPrice($subProduct, $currencyCode, $withTax, []);
169+
$tierPrice = $this->getTierPrice($subProduct, $currencyCode, $withTax);
161170
$price = $this->getTaxPrice($product, $subProduct->getPriceModel()->getFinalPrice(1, $subProduct), $withTax);
162-
$groupPriceList[$groupId]['min'] = min($min, $price);
171+
if (!empty($tierPrice[$groupId]) && $specialPrice[$groupId] > $tierPrice[$groupId]){
172+
$minPrice = $tierPrice[$groupId];
173+
}
174+
$groupPriceList[$groupId]['min'] = min($minPrice, $price);
163175
$groupPriceList[$groupId]['max'] = max($max, $price);
164176
$subProduct->setData('customer_group_id', null);
165177
}

0 commit comments

Comments
 (0)