Skip to content

Commit 0bf8202

Browse files
committed
MAGETWO-98603: [2.3] Fixed Tier Pricing for Bundle items doesn't work
1 parent 4a70baf commit 0bf8202

File tree

2 files changed

+79
-76
lines changed

2 files changed

+79
-76
lines changed

app/code/Magento/Bundle/Block/Catalog/Product/View/Type/Bundle/Option.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ protected function assignSelection(\Magento\Bundle\Model\Option $option, $select
171171
{
172172
if (is_array($selectionId)) {
173173
$this->_selectedOptions = $selectionId;
174-
} else if ($selectionId && $option->getSelectionById($selectionId)) {
174+
} elseif ($selectionId && $option->getSelectionById($selectionId)) {
175175
$this->_selectedOptions = $selectionId;
176176
} elseif (!$option->getRequired()) {
177177
$this->_selectedOptions = 'None';
@@ -301,7 +301,7 @@ public function getSelectionTitlePrice($selection, $includeContainer = true)
301301
*/
302302
public function setValidationContainer($elementId, $containerId)
303303
{
304-
return;
304+
return '';
305305
}
306306

307307
/**

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

Lines changed: 77 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -258,67 +258,68 @@ public function getTotalPrices($product, $which = null, $includeTax = null, $tak
258258
foreach ($options as $option) {
259259
/* @var $option \Magento\Bundle\Model\Option */
260260
$selections = $option->getSelections();
261-
if ($selections) {
262-
$selectionMinimalPrices = [];
263-
$selectionMaximalPrices = [];
264-
265-
foreach ($option->getSelections() as $selection) {
266-
/* @var $selection \Magento\Bundle\Model\Selection */
267-
if (!$selection->isSalable()) {
268-
/**
269-
* @todo CatalogInventory Show out of stock Products
270-
*/
271-
continue;
272-
}
273-
274-
$qty = $selection->getSelectionQty();
275-
276-
$item = $product->getPriceType() == self::PRICE_TYPE_FIXED ? $product : $selection;
277-
278-
$selectionMinimalPrices[] = $this->_catalogData->getTaxPrice(
279-
$item,
280-
$this->getSelectionFinalTotalPrice(
281-
$product,
282-
$selection,
283-
1,
284-
$qty,
285-
true,
286-
$takeTierPrice
287-
),
288-
$includeTax
289-
);
290-
$selectionMaximalPrices[] = $this->_catalogData->getTaxPrice(
291-
$item,
292-
$this->getSelectionFinalTotalPrice(
293-
$product,
294-
$selection,
295-
1,
296-
null,
297-
true,
298-
$takeTierPrice
299-
),
300-
$includeTax
261+
if (empty($selections)) {
262+
continue;
263+
}
264+
$selectionMinimalPrices = [];
265+
$selectionMaximalPrices = [];
266+
267+
foreach ($option->getSelections() as $selection) {
268+
/* @var $selection \Magento\Bundle\Model\Selection */
269+
if (!$selection->isSalable()) {
270+
/**
271+
* @todo CatalogInventory Show out of stock Products
272+
*/
273+
continue;
274+
}
275+
276+
$qty = $selection->getSelectionQty();
277+
278+
$item = $product->getPriceType() == self::PRICE_TYPE_FIXED ? $product : $selection;
279+
280+
$selectionMinimalPrices[] = $this->_catalogData->getTaxPrice(
281+
$item,
282+
$this->getSelectionFinalTotalPrice(
283+
$product,
284+
$selection,
285+
1,
286+
$qty,
287+
true,
288+
$takeTierPrice
289+
),
290+
$includeTax
291+
);
292+
$selectionMaximalPrices[] = $this->_catalogData->getTaxPrice(
293+
$item,
294+
$this->getSelectionFinalTotalPrice(
295+
$product,
296+
$selection,
297+
1,
298+
null,
299+
true,
300+
$takeTierPrice
301+
),
302+
$includeTax
303+
);
304+
}
305+
306+
if (count($selectionMinimalPrices)) {
307+
$selMinPrice = min($selectionMinimalPrices);
308+
if ($option->getRequired()) {
309+
$minimalPrice += $selMinPrice;
310+
$minPriceFounded = true;
311+
} elseif (true !== $minPriceFounded) {
312+
$selMinPrice += $minimalPrice;
313+
$minPriceFounded = false === $minPriceFounded ? $selMinPrice : min(
314+
$minPriceFounded,
315+
$selMinPrice
301316
);
302317
}
303318

304-
if (count($selectionMinimalPrices)) {
305-
$selMinPrice = min($selectionMinimalPrices);
306-
if ($option->getRequired()) {
307-
$minimalPrice += $selMinPrice;
308-
$minPriceFounded = true;
309-
} elseif (true !== $minPriceFounded) {
310-
$selMinPrice += $minimalPrice;
311-
$minPriceFounded = false === $minPriceFounded ? $selMinPrice : min(
312-
$minPriceFounded,
313-
$selMinPrice
314-
);
315-
}
316-
317-
if ($option->isMultiSelection()) {
318-
$maximalPrice += array_sum($selectionMaximalPrices);
319-
} else {
320-
$maximalPrice += max($selectionMaximalPrices);
321-
}
319+
if ($option->isMultiSelection()) {
320+
$maximalPrice += array_sum($selectionMaximalPrices);
321+
} else {
322+
$maximalPrice += max($selectionMaximalPrices);
322323
}
323324
}
324325
}
@@ -341,23 +342,25 @@ public function getTotalPrices($product, $which = null, $includeTax = null, $tak
341342

342343
$prices[] = $valuePrice;
343344
}
344-
if (count($prices)) {
345-
if ($customOption->getIsRequire()) {
346-
$minimalPrice += $this->_catalogData->getTaxPrice($product, min($prices), $includeTax);
347-
}
348-
349-
$multiTypes = [
350-
\Magento\Catalog\Api\Data\ProductCustomOptionInterface::OPTION_TYPE_CHECKBOX,
351-
\Magento\Catalog\Api\Data\ProductCustomOptionInterface::OPTION_TYPE_MULTIPLE,
352-
];
353-
354-
if (in_array($customOption->getType(), $multiTypes)) {
355-
$maximalValue = array_sum($prices);
356-
} else {
357-
$maximalValue = max($prices);
358-
}
359-
$maximalPrice += $this->_catalogData->getTaxPrice($product, $maximalValue, $includeTax);
345+
if (empty($prices)) {
346+
continue;
347+
}
348+
349+
if ($customOption->getIsRequire()) {
350+
$minimalPrice += $this->_catalogData->getTaxPrice($product, min($prices), $includeTax);
351+
}
352+
353+
$multiTypes = [
354+
\Magento\Catalog\Api\Data\ProductCustomOptionInterface::OPTION_TYPE_CHECKBOX,
355+
\Magento\Catalog\Api\Data\ProductCustomOptionInterface::OPTION_TYPE_MULTIPLE,
356+
];
357+
358+
if (in_array($customOption->getType(), $multiTypes)) {
359+
$maximalValue = array_sum($prices);
360+
} else {
361+
$maximalValue = max($prices);
360362
}
363+
$maximalPrice += $this->_catalogData->getTaxPrice($product, $maximalValue, $includeTax);
361364
} else {
362365
$valuePrice = $customOption->getPrice(true);
363366

0 commit comments

Comments
 (0)