Skip to content

Commit 5982aae

Browse files
committed
MAGETWO-96488: Wrong price calculation for bundle product on creating order from the admin panel
1 parent f54fd91 commit 5982aae

File tree

5 files changed

+55
-11
lines changed

5 files changed

+55
-11
lines changed

app/code/Magento/Bundle/Block/Adminhtml/Catalog/Product/Composite/Fieldset/Options/Type/Checkbox.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@ class Checkbox extends \Magento\Bundle\Block\Catalog\Product\View\Type\Bundle\Op
2020
protected $_template = 'Magento_Bundle::product/composite/fieldset/options/type/checkbox.phtml';
2121

2222
/**
23-
* @param string $elementId
24-
* @param string $containerId
25-
* @return string
23+
* @inheritdoc
2624
*/
2725
public function setValidationContainer($elementId, $containerId)
2826
{
@@ -34,4 +32,15 @@ public function setValidationContainer($elementId, $containerId)
3432
'\';
3533
</script>';
3634
}
35+
36+
/**
37+
* @inheritdoc
38+
*/
39+
public function getSelectionPrice($selection)
40+
{
41+
$price = parent::getSelectionPrice($selection);
42+
$qty = $selection->getSelectionQty();
43+
44+
return $price * $qty;
45+
}
3746
}

app/code/Magento/Bundle/Block/Adminhtml/Catalog/Product/Composite/Fieldset/Options/Type/Multi.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@ class Multi extends \Magento\Bundle\Block\Catalog\Product\View\Type\Bundle\Optio
2020
protected $_template = 'Magento_Bundle::product/composite/fieldset/options/type/multi.phtml';
2121

2222
/**
23-
* @param string $elementId
24-
* @param string $containerId
25-
* @return string
23+
* @inheritdoc
2624
*/
2725
public function setValidationContainer($elementId, $containerId)
2826
{
@@ -34,4 +32,15 @@ public function setValidationContainer($elementId, $containerId)
3432
'\';
3533
</script>';
3634
}
35+
36+
/**
37+
* @inheritdoc
38+
*/
39+
public function getSelectionPrice($selection)
40+
{
41+
$price = parent::getSelectionPrice($selection);
42+
$qty = $selection->getSelectionQty();
43+
44+
return $price * $qty;
45+
}
3746
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,8 @@ public function getSelectionPrice($selection)
264264
if ($selection) {
265265
$price = $this->getProduct()->getPriceModel()->getSelectionPreFinalPrice(
266266
$this->getProduct(),
267-
$selection
267+
$selection,
268+
1
268269
);
269270
if (is_numeric($price)) {
270271
$price = $this->pricingHelper->currencyByStore($price, $store, false);

app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderWithBundleProductTest.xml

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@
3232

3333
<!--Create bundle product with checkbox bundle option-->
3434
<createData entity="ApiBundleProduct" stepKey="product"/>
35-
<createData entity="CheckboxOption" stepKey="bundleOption">
35+
<createData entity="CheckboxOption" stepKey="checkboxBundleOption">
3636
<requiredEntity createDataKey="product"/>
3737
</createData>
3838

3939
<!--Link simple product 1 to bundle option with default quantity 2-->
4040
<createData entity="ApiBundleLink" stepKey="createBundleLink1">
4141
<requiredEntity createDataKey="product"/>
42-
<requiredEntity createDataKey="bundleOption"/>
42+
<requiredEntity createDataKey="checkboxBundleOption"/>
4343
<requiredEntity createDataKey="simple1"/>
4444
<field key="qty">2</field>
4545
<field key="is_default">1</field>
@@ -48,11 +48,33 @@
4848
<!--Link simple product 2 to bundle option with default quantity 2-->
4949
<createData entity="ApiBundleLink" stepKey="createBundleLink2">
5050
<requiredEntity createDataKey="product"/>
51-
<requiredEntity createDataKey="bundleOption"/>
51+
<requiredEntity createDataKey="checkboxBundleOption"/>
5252
<requiredEntity createDataKey="simple2"/>
5353
<field key="qty">2</field>
5454
<field key="is_default">1</field>
5555
</createData>
56+
57+
<!--Add drop-down bundle option-->
58+
<createData entity="DropDownBundleOption" stepKey="dropDownBundleOption">
59+
<requiredEntity createDataKey="product"/>
60+
</createData>
61+
62+
<!--Link simple product 1 to drop-down bundle option with default quantity 2-->
63+
<createData entity="ApiBundleLink" stepKey="createBundleLink3">
64+
<requiredEntity createDataKey="product"/>
65+
<requiredEntity createDataKey="dropDownBundleOption"/>
66+
<requiredEntity createDataKey="simple1"/>
67+
<field key="qty">2</field>
68+
<field key="is_default">1</field>
69+
</createData>
70+
71+
<!--Link simple product 2 to drop-down bundle option with default quantity 2-->
72+
<createData entity="ApiBundleLink" stepKey="createBundleLink4">
73+
<requiredEntity createDataKey="product"/>
74+
<requiredEntity createDataKey="dropDownBundleOption"/>
75+
<requiredEntity createDataKey="simple2"/>
76+
<field key="qty">2</field>
77+
</createData>
5678
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
5779
</before>
5880

@@ -65,7 +87,7 @@
6587
<actionGroup ref="addBundleProductToOrderAndCheckPriceInGrid" stepKey="addBundleProductToOrder">
6688
<argument name="product" value="$$product$$"/>
6789
<argument name="quantity" value="1"/>
68-
<argument name="price" value="$492.00"/>
90+
<argument name="price" value="$738.00"/>
6991
</actionGroup>
7092

7193
<!--Select FlatRate shipping method-->

app/code/Magento/Sales/Test/Mftf/Test/AdminSubmitConfigurableProductOrderTest.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
<severity value="AVERAGE"/>
1717
<testCaseId value="MAGETWO-59633"/>
1818
<group value="Sales"/>
19+
<skip>
20+
<issueId value="MAGETWO-96196"/>
21+
</skip>
1922
</annotations>
2023

2124
<before>

0 commit comments

Comments
 (0)