Skip to content

Commit bdd977d

Browse files
committed
Merge remote-tracking branch 'origin/MAGETWO-53331' into BUGS
2 parents 5b25350 + 7c8ecc6 commit bdd977d

File tree

4 files changed

+64
-2
lines changed

4 files changed

+64
-2
lines changed

app/code/Magento/Bundle/Pricing/Price/BundleSelectionPrice.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public function getValue()
124124
$value = $product->getData('final_price') * ($selectionPriceValue / 100);
125125
} else {
126126
// calculate price for selection type fixed
127-
$value = $this->priceCurrency->convert($selectionPriceValue) * $this->quantity;
127+
$value = $this->priceCurrency->convert($selectionPriceValue);
128128
}
129129
}
130130
if (!$this->useRegularPrice) {

app/code/Magento/Bundle/Test/Unit/Pricing/Price/BundleSelectionPriceTest.php

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,67 @@ public function testGetValueTypeFixedWithoutSelectionPriceType($useRegularPrice)
313313
$this->assertEquals($expectedPrice, $this->selectionPrice->getValue());
314314
}
315315

316+
/**
317+
* test for method getValue with type Fixed and selectionPriceType is empty or zero
318+
*
319+
* @param bool $useRegularPrice
320+
* @dataProvider useRegularPriceDataProvider
321+
*/
322+
public function testFixedPriceWithMultipleQty($useRegularPrice)
323+
{
324+
$qty = 2;
325+
326+
$selectionPrice = new \Magento\Bundle\Pricing\Price\BundleSelectionPrice(
327+
$this->productMock,
328+
$qty,
329+
$this->calculatorMock,
330+
$this->priceCurrencyMock,
331+
$this->bundleMock,
332+
$this->eventManagerMock,
333+
$this->discountCalculatorMock,
334+
$useRegularPrice
335+
);
336+
337+
$this->setupSelectionPrice($useRegularPrice);
338+
$regularPrice = 100.125;
339+
$discountedPrice = 70.453;
340+
$convertedValue = 100.247;
341+
$actualPrice = $useRegularPrice ? $convertedValue : $discountedPrice;
342+
$expectedPrice = $useRegularPrice ? round($convertedValue, 2) : round($discountedPrice, 2);
343+
344+
$this->bundleMock->expects($this->once())
345+
->method('getPriceType')
346+
->will($this->returnValue(\Magento\Bundle\Model\Product\Price::PRICE_TYPE_FIXED));
347+
$this->productMock->expects($this->once())
348+
->method('getSelectionPriceType')
349+
->will($this->returnValue(false));
350+
$this->productMock->expects($this->any())
351+
->method('getSelectionPriceValue')
352+
->will($this->returnValue($regularPrice));
353+
354+
$this->priceCurrencyMock->expects($this->once())
355+
->method('convert')
356+
->with($regularPrice)
357+
->will($this->returnValue($convertedValue));
358+
359+
if (!$useRegularPrice) {
360+
$this->discountCalculatorMock->expects($this->once())
361+
->method('calculateDiscount')
362+
->with(
363+
$this->equalTo($this->bundleMock),
364+
$this->equalTo($convertedValue)
365+
)
366+
->will($this->returnValue($discountedPrice));
367+
}
368+
369+
$this->priceCurrencyMock->expects($this->once())
370+
->method('round')
371+
->with($actualPrice)
372+
->will($this->returnValue($expectedPrice));
373+
374+
$this->assertEquals($expectedPrice, $selectionPrice->getValue());
375+
}
376+
316377
public function useRegularPriceDataProvider()
317378
{
318379
return [

app/code/Magento/Bundle/view/base/web/js/price-bundle.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ define([
5555
this._setOption('priceFormat', priceBox.priceBox('option').priceConfig.priceFormat);
5656
priceBox.priceBox('setDefault', this.options.optionConfig.prices);
5757
}
58-
this._applyQtyFix();
5958
this._applyOptionNodeFix(options);
6059

6160
options.on('change', this._onBundleOptionChanged.bind(this));
@@ -113,6 +112,7 @@ define([
113112
* Helper to fix backend behavior:
114113
* - if default qty large than 1 then backend multiply price in config
115114
*
115+
* @deprecated
116116
* @private
117117
*/
118118
_applyQtyFix: function applyQtyFix() {

app/code/Magento/Wishlist/Model/ResourceModel/Item/Collection.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,7 @@ protected function _assignProducts()
291291
'thumbnail',
292292
'links_purchased_separately',
293293
'links_title',
294+
'price_type'
294295
];
295296

296297
$productCollection->addPriceData()

0 commit comments

Comments
 (0)