Skip to content

Commit 0ba2e70

Browse files
author
Mariana Lashch
committed
Merge branch 'MAGETWO-96488' into port-0412
2 parents 8e9f844 + 5982aae commit 0ba2e70

File tree

6 files changed

+149
-7
lines changed

6 files changed

+149
-7
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/Model/Product/Type.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,7 @@ protected function _prepareProduct(\Magento\Framework\DataObject $buyRequest, $p
737737
* for selection (not for all bundle)
738738
*/
739739
$price = $product->getPriceModel()
740-
->getSelectionFinalTotalPrice($product, $selection, 0, $qty);
740+
->getSelectionFinalTotalPrice($product, $selection, 0, 1);
741741
$attributes = [
742742
'price' => $price,
743743
'qty' => $qty,

app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminOrderActionGroup.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,18 @@
157157
<click selector="{{AdminOrderFormItemsSection.addSelected}}" stepKey="clickAddSelectedProducts"/>
158158
</actionGroup>
159159

160+
<!--Add bundle product to order and check product price in the grid-->
161+
<actionGroup name="addBundleProductToOrderAndCheckPriceInGrid" extends="addBundleProductToOrder">
162+
<arguments>
163+
<argument name="price" type="string"/>
164+
</arguments>
165+
<grabTextFrom selector="{{AdminOrderFormItemsSection.rowPrice('1')}}" stepKey="grabProductPriceFromGrid" after="clickOk"/>
166+
<assertEquals stepKey="assertProductPriceInGrid" message="Bundle product price in grid should be equal {{price}}" after="grabProductPriceFromGrid">
167+
<expectedResult type="string">{{price}}</expectedResult>
168+
<actualResult type="variable">grabProductPriceFromGrid</actualResult>
169+
</assertEquals>
170+
</actionGroup>
171+
160172
<!--Add downloadable product to order -->
161173
<actionGroup name="addDownloadableProductToOrder">
162174
<arguments>

app/code/Magento/Sales/Test/Mftf/Section/AdminOrderFormItemsSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
<element name="row" type="text" selector="#sales_order_create_search_grid_table > tbody tr:nth-of-type({{row}})" parameterized="true"/>
2727
<element name="rowCheck" type="checkbox" selector="#sales_order_create_search_grid_table > tbody tr:nth-of-type({{row}}) td.col-select [type=checkbox]" parameterized="true"/>
2828
<element name="rowQty" type="input" selector="#sales_order_create_search_grid_table > tbody tr:nth-of-type({{row}}) td.col-qty [name='qty']" parameterized="true"/>
29+
<element name="rowPrice" type="text" selector="#sales_order_create_search_grid_table > tbody tr:nth-of-type({{row}}) td.price" parameterized="true"/>
2930
<element name="addSelected" type="button" selector="#order-search .admin__page-section-title .actions button.action-add" timeout="30"/>
3031
<element name="customPriceCheckbox" type="checkbox" selector="//*[@class='custom-price-block']/input"/>
3132
<element name="customPriceField" type="input" selector="//*[@class='custom-price-block']/following-sibling::input"/>
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/testSchema.xsd">
10+
<test name="AdminCreateOrderWithBundleProductTest">
11+
<annotations>
12+
<title value="Create Order in Admin and update bundle product configuration"/>
13+
<stories value="MAGETWO-96488: Wrong price calculation for bundle product on creating order from the admin panel"/>
14+
<description value="Add bundle product with bundle option items with default quantity 2 to order in Admin and check price in product grid"/>
15+
<features value="Sales"/>
16+
<severity value="AVERAGE"/>
17+
<group value="Sales"/>
18+
</annotations>
19+
20+
<before>
21+
<!--Set default flat rate shipping method settings-->
22+
<createData entity="FlatRateShippingMethodDefault" stepKey="setDefaultFlatRateShippingMethod"/>
23+
24+
<!--Create simple customer-->
25+
<createData entity="Simple_US_Customer_CA" stepKey="simpleCustomer"/>
26+
27+
<!--Create simple product 1-->
28+
<createData entity="ApiProductWithDescription" stepKey="simple1" before="simple2"/>
29+
30+
<!--Create simple product 2-->
31+
<createData entity="ApiProductWithDescription" stepKey="simple2" before="product"/>
32+
33+
<!--Create bundle product with checkbox bundle option-->
34+
<createData entity="ApiBundleProduct" stepKey="product"/>
35+
<createData entity="CheckboxOption" stepKey="checkboxBundleOption">
36+
<requiredEntity createDataKey="product"/>
37+
</createData>
38+
39+
<!--Link simple product 1 to bundle option with default quantity 2-->
40+
<createData entity="ApiBundleLink" stepKey="createBundleLink1">
41+
<requiredEntity createDataKey="product"/>
42+
<requiredEntity createDataKey="checkboxBundleOption"/>
43+
<requiredEntity createDataKey="simple1"/>
44+
<field key="qty">2</field>
45+
<field key="is_default">1</field>
46+
</createData>
47+
48+
<!--Link simple product 2 to bundle option with default quantity 2-->
49+
<createData entity="ApiBundleLink" stepKey="createBundleLink2">
50+
<requiredEntity createDataKey="product"/>
51+
<requiredEntity createDataKey="checkboxBundleOption"/>
52+
<requiredEntity createDataKey="simple2"/>
53+
<field key="qty">2</field>
54+
<field key="is_default">1</field>
55+
</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>
78+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
79+
</before>
80+
81+
<!--Create new customer order-->
82+
<actionGroup ref="navigateToNewOrderPageExistingCustomer" stepKey="navigateToNewOrderWithExistingCustomer">
83+
<argument name="customer" value="$$simpleCustomer$$"/>
84+
</actionGroup>
85+
86+
<!--Add bundle product to order and check product price in grid-->
87+
<actionGroup ref="addBundleProductToOrderAndCheckPriceInGrid" stepKey="addBundleProductToOrder">
88+
<argument name="product" value="$$product$$"/>
89+
<argument name="quantity" value="1"/>
90+
<argument name="price" value="$738.00"/>
91+
</actionGroup>
92+
93+
<!--Select FlatRate shipping method-->
94+
<actionGroup ref="orderSelectFlatRateShipping" stepKey="orderSelectFlatRateShippingMethod"/>
95+
96+
<!--Submit order-->
97+
<click selector="{{AdminOrderFormActionSection.SubmitOrder}}" stepKey="submitOrder"/>
98+
99+
<!--Verify order information-->
100+
<actionGroup ref="verifyCreatedOrderInformation" stepKey="verifyCreatedOrderInformation"/>
101+
102+
<after>
103+
<actionGroup ref="logout" stepKey="logout"/>
104+
105+
<deleteData createDataKey="product" stepKey="delete"/>
106+
<deleteData createDataKey="simpleCustomer" stepKey="deleteSimpleCustomer"/>
107+
<deleteData createDataKey="simple1" stepKey="deleteSimple1" before="deleteSimple2"/>
108+
<deleteData createDataKey="simple2" stepKey="deleteSimple2" before="delete"/>
109+
</after>
110+
</test>
111+
</tests>

0 commit comments

Comments
 (0)