Skip to content

Commit 0aed6d3

Browse files
MAGETWO-99691: Reorder doesn't show discount price in Order Totals block
1 parent 15100ac commit 0aed6d3

File tree

7 files changed

+131
-3
lines changed

7 files changed

+131
-3
lines changed

app/code/Magento/CatalogRule/Test/Mftf/ActionGroup/CatalogPriceRuleActionGroup.xml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,4 +115,25 @@
115115
<actionGroup name="selectNotLoggedInCustomerGroupActionGroup">
116116
<selectOption selector="{{AdminNewCatalogPriceRule.customerGroups}}" userInput="NOT LOGGED IN" stepKey="selectCustomerGroup"/>
117117
</actionGroup>
118+
119+
<!-- Open rule for Edit -->
120+
<actionGroup name="OpenCatalogPriceRule">
121+
<arguments>
122+
<argument name="ruleName" type="string" defaultValue="CustomCatalogRule.name"/>
123+
</arguments>
124+
<amOnPage url="{{AdminCatalogPriceRuleGridPage.url}}" stepKey="goToAdminCatalogPriceRuleGridPage"/>
125+
<conditionalClick selector="{{AdminDataGridHeaderSection.clearFilters}}" dependentSelector="{{AdminDataGridHeaderSection.clearFilters}}" visible="true" stepKey="clearExistingFilters"/>
126+
<fillField selector="{{AdminCatalogPriceRuleGridSection.filterByRuleName}}" userInput="{{ruleName}}" stepKey="filterByRuleName"/>
127+
<click selector="{{AdminDataGridHeaderSection.applyFilters}}" stepKey="clickSearch"/>
128+
<click selector="{{AdminGridTableSection.row('1')}}" stepKey="clickEdit"/>
129+
<waitForPageLoad stepKey="waitForPageLoad"/>
130+
</actionGroup>
131+
132+
<actionGroup name="RemoveCatalogPriceRule" extends="OpenCatalogPriceRule">
133+
<click selector="{{AdminMainActionsSection.delete}}" after="waitForPageLoad" stepKey="clickToDelete"/>
134+
<waitForElementVisible selector="{{AdminConfirmationModalSection.ok}}" after="clickToDelete" stepKey="waitForElementVisible"/>
135+
<click selector="{{AdminConfirmationModalSection.ok}}" after="waitForElementVisible" stepKey="clickToConfirm"/>
136+
<waitForElementVisible selector="{{AdminMessagesSection.success}}" after="clickToConfirm" stepKey="waitForSuccessMessage"/>
137+
<see selector="{{AdminMessagesSection.success}}" userInput="You deleted the rule." after="waitForSuccessMessage" stepKey="verifyRuleIsDeleted"/>
138+
</actionGroup>
118139
</actionGroups>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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+
9+
<pages xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/PageObject.xsd">
11+
<page name="AdminCatalogPriceRuleGridPage" url="catalog_rule/promo_catalog/" module="Magento_CatalogRule" area="admin">
12+
<section name="AdminCatalogPriceRuleGridSection"/>
13+
</page>
14+
</pages>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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+
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
10+
<section name="AdminCatalogPriceRuleGridSection">
11+
<element name="filterByRuleName" type="input" selector="#promo_catalog_grid_filter_name"/>
12+
<element name="attribute" type="text" selector="//*[@id='promo_catalog_grid_table']//td[contains(text(), '{{arg}}')]" parameterized="true"/>
13+
<element name="applyRulesButton" type="button" selector="#apply_rules" timeout="30"/>
14+
</section>
15+
</sections>

app/code/Magento/Sales/Controller/Adminhtml/Order/Create/Index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class Index extends \Magento\Sales\Controller\Adminhtml\Order\Create implements
2020
public function execute()
2121
{
2222
$this->_initSession();
23-
23+
$this->_getOrderCreateModel()->initRuleData();
2424
/** @var \Magento\Backend\Model\View\Result\Page $resultPage */
2525
$resultPage = $this->resultPageFactory->create();
2626
$resultPage->setActiveMenu('Magento_Sales::sales_order');

app/code/Magento/Sales/Model/AdminOrder/Create.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,7 @@ protected function _getQuoteItem($item)
398398
*/
399399
public function initRuleData()
400400
{
401+
$this->_coreRegistry->unregister('rule_data');
401402
$this->_coreRegistry->register(
402403
'rule_data',
403404
new \Magento\Framework\DataObject(
@@ -415,7 +416,8 @@ public function initRuleData()
415416
/**
416417
* Set collect totals flag for quote
417418
*
418-
* @param bool $flag
419+
* @param bool $flag
420+
*
419421
* @return $this
420422
*/
421423
public function setRecollect($flag)
@@ -1129,6 +1131,7 @@ public function updateQuoteItems($items)
11291131
} catch (\Magento\Framework\Exception\LocalizedException $e) {
11301132
$this->recollectCart();
11311133
throw $e;
1134+
// phpcs:ignore Magento2.Exceptions.ThrowCatch
11321135
} catch (\Exception $e) {
11331136
$this->_logger->critical($e);
11341137
}
@@ -1790,7 +1793,7 @@ public function _prepareCustomer()
17901793
->setWebsiteId($store->getWebsiteId())
17911794
->setCreatedAt(null);
17921795
$customer = $this->_validateCustomerData($customer);
1793-
} else if (!$customer->getId()) {
1796+
} elseif (!$customer->getId()) {
17941797
/** Create new customer */
17951798
$customerBillingAddressDataObject = $this->getBillingAddress()->exportCustomerAddress();
17961799
$customer->setSuffix($customerBillingAddressDataObject->getSuffix())
@@ -1862,6 +1865,7 @@ protected function _prepareCustomerAddress($customer, $quoteCustomerAddress)
18621865
} elseif ($addressType == \Magento\Quote\Model\Quote\Address::ADDRESS_TYPE_SHIPPING) {
18631866
try {
18641867
$billingAddressDataObject = $this->accountManagement->getDefaultBillingAddress($customer->getId());
1868+
// phpcs:ignore Magento2.CodeAnalysis.EmptyBlock
18651869
} catch (\Exception $e) {
18661870
/** Billing address does not exist. */
18671871
}
@@ -2003,6 +2007,7 @@ protected function _validate()
20032007
} else {
20042008
try {
20052009
$method->validate();
2010+
// phpcs:ignore Magento2.Exceptions.ThrowCatch
20062011
} catch (\Magento\Framework\Exception\LocalizedException $e) {
20072012
$this->_errors[] = $e->getMessage();
20082013
}

app/code/Magento/Sales/Test/Mftf/Data/OrderData.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@
2323
<data key="from">200</data>
2424
<data key="to">400</data>
2525
</entity>
26+
<entity name="AdminOrderSimpleProductWithCatalogRule" type="order">
27+
<data key="subtotal">110.70</data>
28+
<data key="shipping">5.00</data>
29+
<data key="grandTotal">115.70</data>
30+
</entity>
2631

2732
<entity name="OrderStatus" type="status">
2833
<data key="canceled">Canceled</data>
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
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="urn:magento:mftf:Test/etc/testSchema.xsd">
10+
<test name="AdminReorderWithCatalogPriceTest">
11+
<annotations>
12+
<features value="Sales"/>
13+
<stories value="Admin create order"/>
14+
<title value="Reorder doesn't show discount price in Order Totals block"/>
15+
<description value="Reorder doesn't show discount price in Order Totals block"/>
16+
<severity value="CRITICAL"/>
17+
<testCaseId value="MC-16695"/>
18+
<useCaseId value="MAGETWO-99691"/>
19+
<group value="sales"/>
20+
<group value="catalogRule"/>
21+
</annotations>
22+
<before>
23+
<!--Create the catalog price rule -->
24+
<createData entity="CatalogRuleToPercent" stepKey="createCatalogRule"/>
25+
<!--Create product-->
26+
<createData entity="SimpleProduct2" stepKey="createSimpleProductApi"/>
27+
<!--Create order via API-->
28+
<createData entity="GuestCart" stepKey="createGuestCart"/>
29+
<createData entity="SimpleCartItem" stepKey="addCartItem">
30+
<requiredEntity createDataKey="createGuestCart"/>
31+
<requiredEntity createDataKey="createSimpleProductApi"/>
32+
</createData>
33+
<createData entity="GuestAddressInformation" stepKey="addGuestOrderAddress">
34+
<requiredEntity createDataKey="createGuestCart"/>
35+
</createData>
36+
<updateData createDataKey="createGuestCart" entity="GuestOrderPaymentMethod" stepKey="sendGuestPaymentInformation">
37+
<requiredEntity createDataKey="createGuestCart"/>
38+
</updateData>
39+
<!--END Create order via API-->
40+
</before>
41+
<after>
42+
<deleteData createDataKey="createSimpleProductApi" stepKey="deleteSimpleProductApi"/>
43+
<!-- Delete the rule -->
44+
<actionGroup ref="RemoveCatalogPriceRule" stepKey="deletePriceRule">
45+
<argument name="ruleName" value="{{CatalogRuleToPercent.name}}" />
46+
</actionGroup>
47+
<!--Clear all filters in grid-->
48+
<amOnPage url="{{AdminOrdersPage.url}}" stepKey="onOrdersPage"/>
49+
<actionGroup ref="clearFiltersAdminDataGrid" stepKey="clearGridFilter"/>
50+
</after>
51+
<!-- Login as admin -->
52+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
53+
<!--Open order by Id-->
54+
<actionGroup ref="OpenOrderById" stepKey="openOrderById">
55+
<argument name="orderId" value="$createGuestCart.return$"/>
56+
</actionGroup>
57+
<!--Reorder-->
58+
<click selector="{{AdminOrderDetailsMainActionsSection.reorder}}" stepKey="clickReorder"/>
59+
<!--Verify totals on Order page-->
60+
<scrollTo selector="{{AdminOrderFormTotalSection.grandTotal}}" stepKey="scrollToOrderGrandTotal"/>
61+
<waitForElementVisible selector="{{AdminOrderFormTotalSection.total('Subtotal')}}" stepKey="waitOrderSubtotalToBeVisible"/>
62+
<see selector="{{AdminOrderFormTotalSection.total('Subtotal')}}" userInput="${{AdminOrderSimpleProductWithCatalogRule.subtotal}}" stepKey="seeOrderSubTotal"/>
63+
<waitForElementVisible selector="{{AdminOrderFormTotalSection.total('Shipping')}}" stepKey="waitOrderShippingToBeVisible"/>
64+
<see selector="{{AdminOrderFormTotalSection.total('Shipping')}}" userInput="${{AdminOrderSimpleProductWithCatalogRule.shipping}}" stepKey="seeOrderShipping"/>
65+
<waitForElementVisible selector="{{AdminOrderFormTotalSection.grandTotal}}" stepKey="waitOrderGrandTotalToBeVisible"/>
66+
<see selector="{{AdminOrderFormTotalSection.grandTotal}}" userInput="${{AdminOrderSimpleProductWithCatalogRule.grandTotal}}" stepKey="seeCorrectGrandTotal"/>
67+
</test>
68+
</tests>

0 commit comments

Comments
 (0)