Skip to content

Commit 5849cd4

Browse files
committed
MAGE-1180: made requested changes
1 parent 663abcf commit 5849cd4

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

Helper/Entity/Product/PriceManager/ProductWithChildren.php

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77

88
abstract class ProductWithChildren extends ProductWithoutChildren
99
{
10+
11+
const PRICE_NOT_SET = -1;
12+
1013
/**
1114
* @param $product
1215
* @param $withTax
@@ -158,8 +161,8 @@ protected function setFinalGroupPrices($field, $currencyCode, $min, $max, $dashe
158161
{
159162
if (count($subproducts) > 0) {
160163
$groupPriceList = [];
161-
$subProductsMin = -1;
162-
$subProductsMax = 0;
164+
$subProductsMin = self::PRICE_NOT_SET;
165+
$subProductsMax = self::PRICE_NOT_SET;
163166
/** @var Group $group */
164167
foreach ($this->groups as $group) {
165168
$groupId = (int) $group->getData('customer_group_id');
@@ -172,30 +175,25 @@ protected function setFinalGroupPrices($field, $currencyCode, $min, $max, $dashe
172175
$tierPrice = $this->getTierPrice($subProduct, $currencyCode, $withTax);
173176
$price = $this->getTaxPrice($product, $subProduct->getPriceModel()->getFinalPrice(1, $subProduct), $withTax);
174177

175-
if (!empty($tierPrice[$groupId]) && $specialPrice[$groupId] > $tierPrice[$groupId]){
176-
$minPrice = $tierPrice[$groupId];
177-
}
178-
179-
if (isset($tierPrice[$groupId]) && $tierPrice[$groupId] !== false) {
178+
if (!empty($tierPrice[$groupId]) && $specialPrice[$groupId] > $tierPrice[$groupId]) {
180179
$minPrice = $tierPrice[$groupId];
181180
}
182181

183-
if ($subProductsMin == -1 || $price < $subProductsMin) {
182+
if ($subProductsMin === self::PRICE_NOT_SET || $price < $subProductsMin) {
184183
$subProductsMin = $price;
185184
}
186185

187-
if ($price > $subProductsMax) {
186+
if ($subProductsMax === self::PRICE_NOT_SET || $price > $subProductsMax) {
188187
$subProductsMax = $price;
189188
}
190189

191190
$groupPriceList[$groupId]['min'] = min($minPrice, $subProductsMin);
192191
$groupPriceList[$groupId]['max'] = $subProductsMax;
193192
$subProduct->setData('customer_group_id', null);
194-
195193
}
196194

197-
$subProductsMin = -1;
198-
$subProductsMax = 0;
195+
$subProductsMin = self::PRICE_NOT_SET;
196+
$subProductsMax = self::PRICE_NOT_SET;
199197
}
200198

201199
$minArray = [];

0 commit comments

Comments
 (0)