Skip to content
This repository was archived by the owner on Dec 19, 2019. It is now read-only.

Commit f8ae7f5

Browse files
committed
Merge remote-tracking branch 'origin/2.3-develop' into MC-16108
2 parents bcc3cf0 + d585442 commit f8ae7f5

File tree

7 files changed

+96
-88
lines changed

7 files changed

+96
-88
lines changed

app/code/Magento/Multishipping/Model/Checkout/Type/Multishipping.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,9 @@ public function setPaymentMethod($payment)
662662
$quote->getPayment()->importData($payment);
663663
// shipping totals may be affected by payment method
664664
if (!$quote->isVirtual() && $quote->getShippingAddress()) {
665-
$quote->getShippingAddress()->setCollectShippingRates(true);
665+
foreach ($quote->getAllShippingAddresses() as $shippingAddress) {
666+
$shippingAddress->setCollectShippingRates(true);
667+
}
666668
$quote->setTotalsCollectedFlag(false)->collectTotals();
667669
}
668670
$this->quoteRepository->save($quote);
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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+
<entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataProfileSchema.xsd">
11+
<entity name="CartPriceRuleConditionForSubtotalForMultiShipping" extends="CartPriceRuleConditionAppliedForSubtotal">
12+
<data key="apply">Percent of product price discount</data>
13+
<data key="customerGroups">'NOT LOGGED IN', 'General', 'Wholesale', 'Retailer'</data>
14+
<data key="subtotal">50</data>
15+
<data key="apply_to_shipping">1</data>
16+
<data key="simple_free_shipping">For matching items only</data>
17+
<data key="condition1">Subtotal</data>
18+
<data key="condition2">Shipping Method</data>
19+
<data key="rule1">equals or greater than</data>
20+
<data key="shippingMethod">[flatrate] Fixed</data>
21+
<data key="ruleToChange1">is</data>
22+
</entity>
23+
</entities>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
11+
<test name="StorefrontCheckingWithCartPriceRuleMatchingSubtotalForMultiShipmentTest" extends="StoreFrontCheckingWithMultishipmentTest">
12+
<annotations>
13+
<features value="Multi shipment and Cart Price Rule"/>
14+
<stories value="Checking cart price rule for multi shipment with multiple shipment addresses on front end order page"/>
15+
<title value="Checking sub total amount and free shipping is applied with multiple shipment addresses on front end order page"/>
16+
<description value="Cart Price Rules not working and free shipping not applied for Multi shipping "/>
17+
<severity value="MAJOR"/>
18+
<testCaseId value="MC-21738"/>
19+
<group value="Multishipment"/>
20+
<group value="SalesRule"/>
21+
</annotations>
22+
<before>
23+
<magentoCLI command="config:set multishipping/options/checkout_multiple 1" stepKey="allowShippingToMultipleAddresses"/>
24+
</before>
25+
<after>
26+
<magentoCLI command="config:set multishipping/options/checkout_multiple 0" stepKey="disableShippingToMultipleAddresses"/>
27+
</after>
28+
<actionGroup ref="AdminCreateCartPriceRuleActionsWithSubtotalActionGroup" before="goToProduct1" stepKey="createSubtotalCartPriceRuleActionsSection">
29+
<argument name="ruleName" value="CartPriceRuleConditionForSubtotalForMultiShipping"/>
30+
</actionGroup>
31+
<actionGroup ref="DeleteCartPriceRuleByName" after="placeOrder" stepKey="deleteCreatedCartPriceRule">
32+
<argument name="ruleName" value="{$getSubtotalRuleCreateSubtotalCartPriceRuleActionsSection}"/>
33+
</actionGroup>
34+
</test>
35+
</tests>

app/code/Magento/SalesRule/Test/Mftf/ActionGroup/AdminCreateCartPriceRuleActionGroup.xml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,33 @@
105105
<waitForElementVisible selector="{{AdminCartPriceRulesFormSection.categoryCheckbox(categoryName)}}" stepKey="waitForCategoryVisible" after="openChooser"/>
106106
<checkOption selector="{{AdminCartPriceRulesFormSection.categoryCheckbox(categoryName)}}" stepKey="checkCategoryName" after="waitForCategoryVisible"/>
107107
</actionGroup>
108+
<actionGroup name="AdminCreateCartPriceRuleActionsWithSubtotalActionGroup" extends="AdminCreateCartPriceRuleActionGroup">
109+
<annotations>
110+
<description>EXTENDS: AdminCreateCartPriceRuleActionGroup. Removes 'fillDiscountAmount'. Adds sub total conditions for free shipping to a Cart Price Rule.</description>
111+
</annotations>
112+
<arguments>
113+
<argument name="ruleName"/>
114+
</arguments>
115+
<remove keyForRemoval="fillDiscountAmount"/>
116+
<!-- Expand the conditions section -->
117+
<grabTextFrom selector="{{AdminCartPriceRulesFormSection.ruleName}}" after="fillRuleName" stepKey="getSubtotalRule"/>
118+
<click selector="{{AdminCartPriceRulesFormSection.conditionsHeader}}" stepKey="openConditionsSection" after="selectActionType"/>
119+
<click selector="{{AdminCartPriceRulesFormSection.addCondition('1')}}" after="openConditionsSection" stepKey="addFirstCondition"/>
120+
<selectOption selector="{{AdminCartPriceRulesFormSection.conditionSelect}}" userInput="{{ruleName.condition1}}" after="addFirstCondition" stepKey="selectCondition1"/>
121+
<waitForPageLoad after="selectCondition1" stepKey="waitForConditionLoad"/>
122+
<click selector="{{AdminCartPriceRulesFormSection.condition(ruleName.ruleToChange1)}}" after="waitForConditionLoad" stepKey="clickToChooseOption"/>
123+
<selectOption selector="{{AdminCartPriceRulesFormSection.conditionsOperator}}" userInput="{{ruleName.rule1}}" after="clickToChooseOption" stepKey="setOperatorType"/>
124+
<click selector="{{AdminCartPriceRulesFormSection.targetEllipsis}}" after="setOperatorType" stepKey="clickEllipsis"/>
125+
<fillField selector="{{AdminCartPriceRulesFormSection.ruleFieldByIndex('1--1')}}" userInput="{{ruleName.subtotal}}" after="clickEllipsis" stepKey="fillSubtotalParameter"/>
126+
<click selector="{{AdminCartPriceRulesFormSection.addNewCondition('1')}}" after="fillSubtotalParameter" stepKey="clickOnTheAddNewCondition"/>
127+
<selectOption selector="{{AdminCartPriceRulesFormSection.conditionSelectDropdown('1')}}" userInput="{{ruleName.condition2}}" after="clickOnTheAddNewCondition" stepKey="selectSecondCondition"/>
128+
<waitForPageLoad after="selectSecondCondition" stepKey="waitForConditionLoad2"/>
129+
<click selector="{{AdminCartPriceRulesFormSection.targetEllipsis}}" after="waitForConditionLoad2" stepKey="clickEllipsis2"/>
130+
<selectOption selector="{{AdminCartPriceRulesFormSection.ruleFieldByIndex('1--2')}}" userInput="{{ruleName.shippingMethod}}" after="clickEllipsis2" stepKey="selectShippingMethod"/>
131+
<click selector="{{AdminCartPriceRulesFormSection.applyToShippingAmount}}" after="selectShippingMethod" stepKey="clickApplyToShipping"/>
132+
<click selector="{{AdminCartPriceRulesFormSection.discardSubsequentRules}}" after="clickApplyToShipping" stepKey="clickDiscardSubsequentRules"/>
133+
<selectOption selector="{{AdminCartPriceRulesFormSection.freeShipping}}" userInput="{{ruleName.simple_free_shipping}}" after="clickDiscardSubsequentRules" stepKey="selectForMatchingItemsOnly"/>
134+
</actionGroup>
108135
<actionGroup name="AdminCreateMultiWebsiteCartPriceRuleActionGroup" extends="AdminCreateCartPriceRuleActionGroup">
109136
<annotations>
110137
<description>EXTENDS: AdminCreateCartPriceRuleActionGroup. Removes 'clickSaveButton' for the next data changing. Assign cart price rule to 2 websites instead of 1.</description>

app/code/Magento/UrlRewrite/Controller/Router.php

Lines changed: 8 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,16 @@
55
*/
66
namespace Magento\UrlRewrite\Controller;
77

8+
use Magento\Framework\App\Action\Redirect;
9+
use Magento\Framework\App\ActionInterface;
10+
use Magento\Framework\App\Request\Http as HttpRequest;
811
use Magento\Framework\App\RequestInterface;
12+
use Magento\Framework\App\Response\Http as HttpResponse;
13+
use Magento\Framework\Exception\NoSuchEntityException;
14+
use Magento\Framework\UrlInterface;
915
use Magento\UrlRewrite\Controller\Adminhtml\Url\Rewrite;
1016
use Magento\UrlRewrite\Model\UrlFinderInterface;
1117
use Magento\UrlRewrite\Service\V1\Data\UrlRewrite;
12-
use Magento\Framework\App\Request\Http as HttpRequest;
13-
use Magento\Framework\App\Response\Http as HttpResponse;
14-
use Magento\Framework\UrlInterface;
15-
use Magento\Framework\App\Action\Redirect;
16-
use Magento\Framework\App\ActionInterface;
1718

1819
/**
1920
* UrlRewrite Controller Router
@@ -73,11 +74,12 @@ public function __construct(
7374
*
7475
* @param RequestInterface|HttpRequest $request
7576
* @return ActionInterface|null
77+
* @throws NoSuchEntityException
7678
*/
7779
public function match(RequestInterface $request)
7880
{
7981
$rewrite = $this->getRewrite(
80-
$this->getNormalizedPathInfo($request),
82+
$request->getPathInfo(),
8183
$this->storeManager->getStore()->getId()
8284
);
8385

@@ -153,30 +155,4 @@ protected function getRewrite($requestPath, $storeId)
153155
]
154156
);
155157
}
156-
157-
/**
158-
* Get normalized request path
159-
*
160-
* @param RequestInterface|HttpRequest $request
161-
* @return string
162-
*/
163-
private function getNormalizedPathInfo(RequestInterface $request): string
164-
{
165-
$path = $request->getPathInfo();
166-
/**
167-
* If request contains query params then we need to trim a slash in end of the path.
168-
* For example:
169-
* the original request is: http://my-host.com/category-url-key.html/?color=black
170-
* where the original path is: category-url-key.html/
171-
* and the result path will be: category-url-key.html
172-
*
173-
* It need to except a redirect like this:
174-
* http://my-host.com/category-url-key.html/?color=black => http://my-host.com/category-url-key.html
175-
*/
176-
if (!empty($path) && $request->getQuery()->count()) {
177-
$path = rtrim($path, '/');
178-
}
179-
180-
return (string)$path;
181-
}
182158
}

app/code/Magento/UrlRewrite/Test/Unit/Controller/RouterTest.php

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -351,54 +351,4 @@ public function testMatch()
351351

352352
$this->router->match($this->request);
353353
}
354-
355-
/**
356-
* Test to match corresponding URL Rewrite on request with query params
357-
*
358-
* @param string $originalRequestPath
359-
* @param string $requestPath
360-
* @param int $countOfQueryParams
361-
* @dataProvider matchWithQueryParamsDataProvider
362-
*/
363-
public function testMatchWithQueryParams(string $originalRequestPath, string $requestPath, int $countOfQueryParams)
364-
{
365-
$targetPath = 'target-path';
366-
367-
$this->storeManager->method('getStore')->willReturn($this->store);
368-
$urlRewrite = $this->createMock(UrlRewrite::class);
369-
$urlRewrite->method('getRedirectType')->willReturn(0);
370-
$urlRewrite->method('getTargetPath')->willReturn($targetPath);
371-
$urlRewrite->method('getRequestPath')->willReturn($requestPath);
372-
$this->urlFinder->method('findOneByData')
373-
->with([UrlRewrite::REQUEST_PATH => $requestPath, UrlRewrite::STORE_ID => $this->store->getId()])
374-
->willReturn($urlRewrite);
375-
376-
$this->requestQuery->method('count')->willReturn($countOfQueryParams);
377-
$this->request->method('getPathInfo')
378-
->willReturn($originalRequestPath);
379-
$this->request->expects($this->once())
380-
->method('setPathInfo')
381-
->with('/' . $targetPath);
382-
$this->request->expects($this->once())
383-
->method('setAlias')
384-
->with(UrlInterface::REWRITE_REQUEST_PATH_ALIAS, $requestPath);
385-
$this->actionFactory->expects($this->once())
386-
->method('create')
387-
->with(Forward::class);
388-
389-
$this->router->match($this->request);
390-
}
391-
392-
/**
393-
* Data provider for Test to match corresponding URL Rewrite on request with query params
394-
*
395-
* @return array
396-
*/
397-
public function matchWithQueryParamsDataProvider(): array
398-
{
399-
return [
400-
['/category.html/', 'category.html/', 0],
401-
['/category.html/', 'category.html', 1],
402-
];
403-
}
404354
}

dev/tests/integration/testsuite/Magento/UrlRewrite/Controller/UrlRewriteTest.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,6 @@ public function requestDataProvider(): array
8080
'request' => '/page-similar/',
8181
'redirect' => '/page-b',
8282
],
83-
'Use Case #7: Request with query params' => [
84-
'request' => '/enable-cookies/?test-param',
85-
'redirect' => '',
86-
HttpResponse::STATUS_CODE_200,
87-
],
8883
];
8984
}
9085

0 commit comments

Comments
 (0)