Skip to content

Commit 515b7ef

Browse files
committed
MAGETWO-96488: Wrong price calculation for bundle product on creating order from the admin panel
1 parent 1a805d0 commit 515b7ef

File tree

6 files changed

+104
-6
lines changed

6 files changed

+104
-6
lines changed

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

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

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
@@ -174,6 +174,18 @@
174174
<click selector="{{AdminOrderFormItemsSection.addSelected}}" stepKey="clickAddSelectedProducts"/>
175175
</actionGroup>
176176

177+
<!--Add bundle product to order and check product price in the grid-->
178+
<actionGroup name="addBundleProductToOrderAndCheckPriceInGrid" extends="addBundleProductToOrder">
179+
<arguments>
180+
<argument name="price" type="string"/>
181+
</arguments>
182+
<grabTextFrom selector="{{AdminOrderFormItemsSection.rowPrice('1')}}" stepKey="grabProductPriceFromGrid" after="clickOk"/>
183+
<assertEquals stepKey="assertProductPriceInGrid" message="Bundle product price in grid should be equal {{price}}" after="grabProductPriceFromGrid">
184+
<expectedResult type="string">{{price}}</expectedResult>
185+
<actualResult type="variable">grabProductPriceFromGrid</actualResult>
186+
</assertEquals>
187+
</actionGroup>
188+
177189
<!--Add downloadable product to order -->
178190
<actionGroup name="addDownloadableProductToOrder">
179191
<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: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
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="bundleOption">
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="bundleOption"/>
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="bundleOption"/>
52+
<requiredEntity createDataKey="simple2"/>
53+
<field key="qty">2</field>
54+
<field key="is_default">1</field>
55+
</createData>
56+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
57+
</before>
58+
59+
<!--Create new customer order-->
60+
<actionGroup ref="navigateToNewOrderPageExistingCustomer" stepKey="navigateToNewOrderWithExistingCustomer">
61+
<argument name="customer" value="$$simpleCustomer$$"/>
62+
</actionGroup>
63+
64+
<!--Add bundle product to order and check product price in grid-->
65+
<actionGroup ref="addBundleProductToOrderAndCheckPriceInGrid" stepKey="addBundleProductToOrder">
66+
<argument name="product" value="$$product$$"/>
67+
<argument name="quantity" value="1"/>
68+
<argument name="price" value="$492.00"/>
69+
</actionGroup>
70+
71+
<!--Select FlatRate shipping method-->
72+
<actionGroup ref="orderSelectFlatRateShipping" stepKey="orderSelectFlatRateShippingMethod"/>
73+
74+
<!--Submit order-->
75+
<click selector="{{AdminOrderFormActionSection.SubmitOrder}}" stepKey="submitOrder"/>
76+
77+
<!--Verify order information-->
78+
<actionGroup ref="verifyCreatedOrderInformation" stepKey="verifyCreatedOrderInformation"/>
79+
80+
<after>
81+
<actionGroup ref="logout" stepKey="logout"/>
82+
83+
<deleteData createDataKey="product" stepKey="delete"/>
84+
<deleteData createDataKey="simpleCustomer" stepKey="deleteSimpleCustomer"/>
85+
<deleteData createDataKey="simple1" stepKey="deleteSimple1" before="deleteSimple2"/>
86+
<deleteData createDataKey="simple2" stepKey="deleteSimple2" before="delete"/>
87+
</after>
88+
</test>
89+
</tests>

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

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

2421
<before>

0 commit comments

Comments
 (0)