@@ -258,67 +258,68 @@ public function getTotalPrices($product, $which = null, $includeTax = null, $tak
258
258
foreach ($ options as $ option ) {
259
259
/* @var $option \Magento\Bundle\Model\Option */
260
260
$ 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
301
316
);
302
317
}
303
318
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 );
322
323
}
323
324
}
324
325
}
@@ -341,23 +342,25 @@ public function getTotalPrices($product, $which = null, $includeTax = null, $tak
341
342
342
343
$ prices [] = $ valuePrice ;
343
344
}
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 );
360
362
}
363
+ $ maximalPrice += $ this ->_catalogData ->getTaxPrice ($ product , $ maximalValue , $ includeTax );
361
364
} else {
362
365
$ valuePrice = $ customOption ->getPrice (true );
363
366
0 commit comments