Skip to content

Commit 91aaeec

Browse files
authored
Merge pull request #6375 from magento-tsg-csl3/2.4-develop-pr46
[TSG-CSL3] For 2.4 (pr46)
2 parents 2106f67 + edaabb8 commit 91aaeec

File tree

32 files changed

+879
-83
lines changed

32 files changed

+879
-83
lines changed

app/code/Magento/Checkout/view/frontend/web/js/action/set-payment-information-extended.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ define([
3030
list[key] = filterTemplateData(value);
3131
}
3232

33-
if (key === '__disableTmpl') {
33+
if (key === '__disableTmpl' || key === 'title') {
3434
delete list[key];
3535
}
3636
});

app/code/Magento/ConfigurableProduct/Controller/Adminhtml/Product/Initialization/Helper/Plugin/UpdateConfigurations.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,9 @@ protected function getConfigurations()
115115
if (isset($item['qty'])) {
116116
$result[$item['id']]['quantity_and_stock_status']['qty'] = $item['qty'];
117117
}
118-
118+
119119
// Changing product to simple on weight change
120-
if (isset($item['weight']) && $item['weight'] >= 0) {
120+
if (!empty($item['weight']) && $item['weight'] >= 0) {
121121
$result[$item['id']]['type_id'] = \Magento\Catalog\Model\Product\Type::TYPE_SIMPLE;
122122
$result[$item['id']]['product_has_weight'] = WeightResolver::HAS_WEIGHT;
123123
}

app/code/Magento/ConfigurableProduct/Test/Unit/Controller/Adminhtml/Product/Initialization/Helper/Plugin/UpdateConfigurationsTest.php

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,22 @@ private function getConfigurableMatrix()
119119
'price' => '3.33',
120120
'weight' => '5.55',
121121
],
122+
[
123+
'newProduct' => false,
124+
'id' => 'product5',
125+
'status' => 'simple5_status',
126+
'sku' => 'simple5_sku',
127+
'name' => 'simple5_name',
128+
'price' => '3.33',
129+
'configurable_attribute' => 'simple5_configurable_attribute',
130+
'weight' => '',
131+
'media_gallery' => 'simple5_media_gallery',
132+
'swatch_image' => 'simple5_swatch_image',
133+
'small_image' => 'simple5_small_image',
134+
'thumbnail' => 'simple5_thumbnail',
135+
'image' => 'simple5_image',
136+
'was_changed' => true,
137+
],
122138
];
123139
}
124140

@@ -144,12 +160,26 @@ public function testAfterInitialize()
144160
],
145161
'product3' => [
146162
'quantity_and_stock_status' => ['qty' => '3']
147-
]
163+
],
164+
'product5' => [
165+
'status' => 'simple5_status',
166+
'sku' => 'simple5_sku',
167+
'name' => 'simple5_name',
168+
'price' => '3.33',
169+
'configurable_attribute' => 'simple5_configurable_attribute',
170+
'weight' => '',
171+
'media_gallery' => 'simple5_media_gallery',
172+
'swatch_image' => 'simple5_swatch_image',
173+
'small_image' => 'simple5_small_image',
174+
'thumbnail' => 'simple5_thumbnail',
175+
'image' => 'simple5_image',
176+
],
148177
];
149178
/** @var Product[]|MockObject[] $productMocks */
150179
$productMocks = [
151180
'product2' => $this->getProductMock($configurations['product2'], true, true),
152181
'product3' => $this->getProductMock($configurations['product3'], false, true),
182+
'product5' => $this->getProductMock($configurations['product5'], false, true),
153183
];
154184

155185
$this->requestMock->expects(static::any())
@@ -169,15 +199,17 @@ public function testAfterInitialize()
169199
->willReturnMap(
170200
[
171201
['product2', false, 0, false, $productMocks['product2']],
172-
['product3', false, 0, false, $productMocks['product3']]
202+
['product3', false, 0, false, $productMocks['product3']],
203+
['product5', false, 0, false, $productMocks['product5']],
173204
]
174205
);
175206
$this->variationHandlerMock->expects(static::any())
176207
->method('processMediaGallery')
177208
->willReturnMap(
178209
[
179210
[$productMocks['product2'], $configurations['product2'], $configurations['product2']],
180-
[$productMocks['product3'], $configurations['product3'], $configurations['product3']]
211+
[$productMocks['product3'], $configurations['product3'], $configurations['product3']],
212+
[$productMocks['product5'], $configurations['product5'], $configurations['product5']]
181213
]
182214
);
183215

app/code/Magento/Customer/ViewModel/Customer/Store.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,12 @@ private function getStoreOptionsWithCurrentWebsiteId(): array
113113
if (!empty($this->dataPersistor->get('customer')['account'])) {
114114
$currentWebsiteId = (string)$this->dataPersistor->get('customer')['account']['website_id'];
115115
} else {
116-
$currentWebsiteId = $this->storeManager->getDefaultStoreView()->getWebsiteId();
116+
$defaultStore = $this->storeManager->getDefaultStoreView();
117+
if (!$defaultStore) {
118+
$stores = $this->storeManager->getStores();
119+
$defaultStore = array_shift($stores);
120+
}
121+
$currentWebsiteId = $defaultStore->getWebsiteId();
117122
}
118123

119124
foreach ($options as $key => $option) {

app/code/Magento/Dhl/Model/Carrier.php

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,23 @@
77
namespace Magento\Dhl\Model;
88

99
use Magento\Catalog\Model\Product\Type;
10+
use Magento\Dhl\Model\Validator\XmlValidator;
1011
use Magento\Framework\App\ObjectManager;
1112
use Magento\Framework\App\ProductMetadataInterface;
1213
use Magento\Framework\Async\CallbackDeferred;
14+
use Magento\Framework\HTTP\AsyncClient\HttpException;
1315
use Magento\Framework\HTTP\AsyncClient\HttpResponseDeferredInterface;
1416
use Magento\Framework\HTTP\AsyncClient\Request;
1517
use Magento\Framework\HTTP\AsyncClientInterface;
1618
use Magento\Framework\Module\Dir;
17-
use Magento\Sales\Exception\DocumentValidationException;
18-
use Magento\Sales\Model\Order\Shipment;
19+
use Magento\Framework\Xml\Security;
1920
use Magento\Quote\Model\Quote\Address\RateRequest;
2021
use Magento\Quote\Model\Quote\Address\RateResult\Error;
22+
use Magento\Sales\Exception\DocumentValidationException;
23+
use Magento\Sales\Model\Order\Shipment;
2124
use Magento\Shipping\Model\Carrier\AbstractCarrier;
2225
use Magento\Shipping\Model\Rate\Result;
2326
use Magento\Shipping\Model\Rate\Result\ProxyDeferredFactory;
24-
use Magento\Framework\Xml\Security;
25-
use Magento\Dhl\Model\Validator\XmlValidator;
2627

2728
/**
2829
* DHL International (API v1.4)
@@ -1064,8 +1065,15 @@ protected function _getQuotes()
10641065
function () use ($deferredResponses, $responseBodies) {
10651066
//Loading rates not found in cache
10661067
foreach ($deferredResponses as $deferredResponseData) {
1068+
$responseResult = null;
1069+
try {
1070+
$responseResult = $deferredResponseData['deferred']->get();
1071+
} catch (HttpException $exception) {
1072+
$this->_logger->critical($exception);
1073+
}
1074+
$responseBody = $responseResult ? $responseResult->getBody() : '';
10671075
$responseBodies[] = [
1068-
'body' => $deferredResponseData['deferred']->get()->getBody(),
1076+
'body' => $responseBody,
10691077
'date' => $deferredResponseData['date'],
10701078
'request' => $deferredResponseData['request'],
10711079
'from_cache' => false
@@ -2028,7 +2036,8 @@ protected function _checkDomesticStatus($origCountryCode, $destCountryCode)
20282036
$isDomestic = (string)$this->getCountryParams($destCountryCode)->getData('domestic');
20292037

20302038
if (($origCountry == $destCountry && $isDomestic)
2031-
|| ($this->_carrierHelper->isCountryInEU($origCountryCode)
2039+
|| (
2040+
$this->_carrierHelper->isCountryInEU($origCountryCode)
20322041
&& $this->_carrierHelper->isCountryInEU($destCountryCode)
20332042
)
20342043
) {

app/code/Magento/Multishipping/Model/Cart/Controller/CartPlugin.php

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use Magento\Framework\App\RequestInterface;
1414
use Magento\Framework\Exception\LocalizedException;
1515
use Magento\Multishipping\Model\Checkout\Type\Multishipping\State;
16+
use Magento\Multishipping\Model\DisableMultishipping;
1617
use Magento\Quote\Api\CartRepositoryInterface;
1718
use Magento\Quote\Model\Quote;
1819

@@ -36,19 +37,27 @@ class CartPlugin
3637
*/
3738
private $addressRepository;
3839

40+
/**
41+
* @var DisableMultishipping
42+
*/
43+
private $disableMultishipping;
44+
3945
/**
4046
* @param CartRepositoryInterface $cartRepository
4147
* @param Session $checkoutSession
4248
* @param AddressRepositoryInterface $addressRepository
49+
* @param DisableMultishipping $disableMultishipping
4350
*/
4451
public function __construct(
4552
CartRepositoryInterface $cartRepository,
4653
Session $checkoutSession,
47-
AddressRepositoryInterface $addressRepository
54+
AddressRepositoryInterface $addressRepository,
55+
DisableMultishipping $disableMultishipping
4856
) {
4957
$this->cartRepository = $cartRepository;
5058
$this->checkoutSession = $checkoutSession;
5159
$this->addressRepository = $addressRepository;
60+
$this->disableMultishipping = $disableMultishipping;
5261
}
5362

5463
/**
@@ -76,6 +85,9 @@ public function beforeDispatch(Cart $subject, RequestInterface $request)
7685
$shippingAddress->importCustomerAddressData($defaultCustomerAddress);
7786
}
7887
$this->cartRepository->save($quote);
88+
} elseif ($this->disableMultishipping->execute($quote) && $this->isVirtualItemInQuote($quote)) {
89+
$quote->setTotalsCollectedFlag(false);
90+
$this->cartRepository->save($quote);
7991
}
8092
}
8193

@@ -88,4 +100,24 @@ private function isCheckoutComplete() : bool
88100
{
89101
return (bool) ($this->checkoutSession->getStepData(State::STEP_SHIPPING)['is_complete'] ?? true);
90102
}
103+
104+
/**
105+
* Checks whether quote has virtual items
106+
*
107+
* @param Quote $quote
108+
* @return bool
109+
*/
110+
private function isVirtualItemInQuote(Quote $quote): bool
111+
{
112+
$items = $quote->getItems();
113+
if (!empty($items)) {
114+
foreach ($items as $item) {
115+
if ($item->getIsVirtual()) {
116+
return true;
117+
}
118+
}
119+
}
120+
121+
return false;
122+
}
91123
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
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="StorefrontDisableMultishippingModeCheckoutOnBackToCartTest">
12+
<annotations>
13+
<features value="Multishipping"/>
14+
<stories value="Multishipping"/>
15+
<title value="Disable multishipping checkout on backing to cart"/>
16+
<description value="Cart page summary block should count virtual product price after backing back to the cart from multishipping checkout."/>
17+
<severity value="CRITICAL"/>
18+
<testCaseId value="MC-39007"/>
19+
<useCaseId value="MC-38825"/>
20+
<group value="multishipping"/>
21+
</annotations>
22+
<before>
23+
<createData entity="ApiCategory" stepKey="createCategory"/>
24+
<createData entity="_defaultProduct" stepKey="createSimpleProduct">
25+
<requiredEntity createDataKey="createCategory"/>
26+
</createData>
27+
<createData entity="VirtualProduct" stepKey="createVirtualProduct">
28+
<requiredEntity createDataKey="createCategory"/>
29+
</createData>
30+
<createData entity="Simple_US_Customer_Multiple_Addresses" stepKey="createCustomerWithMultipleAddresses"/>
31+
</before>
32+
<after>
33+
<deleteData createDataKey="createSimpleProduct" stepKey="deleteSimpleProduct"/>
34+
<deleteData createDataKey="createVirtualProduct" stepKey="deleteVirtualProduct"/>
35+
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
36+
<deleteData createDataKey="createCustomerWithMultipleAddresses" stepKey="deleteCustomer"/>
37+
</after>
38+
<actionGroup ref="LoginToStorefrontActionGroup" stepKey="loginAsCustomer">
39+
<argument name="Customer" value="$createCustomerWithMultipleAddresses$"/>
40+
</actionGroup>
41+
42+
<actionGroup ref="StorefrontOpenProductEntityPageActionGroup" stepKey="openVirtualProductPage">
43+
<argument name="product" value="$createVirtualProduct$"/>
44+
</actionGroup>
45+
<actionGroup ref="StorefrontAddProductToCartActionGroup" stepKey="addVirtualProductToCart">
46+
<argument name="product" value="$createVirtualProduct$"/>
47+
<argument name="productCount" value="1"/>
48+
</actionGroup>
49+
50+
<actionGroup ref="StorefrontOpenProductEntityPageActionGroup" stepKey="openSimpleProductPage">
51+
<argument name="product" value="$createSimpleProduct$"/>
52+
</actionGroup>
53+
<actionGroup ref="StorefrontAddProductToCartActionGroup" stepKey="addSimpleProductToCart">
54+
<argument name="product" value="$createSimpleProduct$"/>
55+
<argument name="productCount" value="2"/>
56+
</actionGroup>
57+
58+
<actionGroup ref="ClickViewAndEditCartFromMiniCartActionGroup" stepKey="goToShoppingCartFromMinicart"/>
59+
<grabTextFrom selector="{{CheckoutPaymentSection.orderSummaryTotal}}" stepKey="grabTotal"/>
60+
61+
<actionGroup ref="StorefrontGoCheckoutWithMultipleAddressesActionGroup" stepKey="goCheckoutWithMultipleAddresses"/>
62+
<actionGroup ref="StorefrontCartPageOpenActionGroup" stepKey="goBackToShoppingCartPage"/>
63+
<actionGroup ref="AssertStorefrontCheckoutPaymentSummaryTotalActionGroup" stepKey="assertSummaryTotal">
64+
<argument name="orderTotal" value="{$grabTotal}"/>
65+
</actionGroup>
66+
</test>
67+
</tests>

app/code/Magento/Multishipping/Test/Unit/Model/Cart/Controller/CartPluginTest.php

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Magento\Customer\Api\Data\CustomerInterface;
1515
use Magento\Framework\App\RequestInterface;
1616
use Magento\Multishipping\Model\Cart\Controller\CartPlugin;
17+
use Magento\Multishipping\Model\DisableMultishipping;
1718
use Magento\Quote\Api\CartRepositoryInterface;
1819
use Magento\Quote\Model\Quote;
1920
use Magento\Quote\Model\Quote\Address;
@@ -47,10 +48,12 @@ protected function setUp(): void
4748
$this->cartRepositoryMock = $this->getMockForAbstractClass(CartRepositoryInterface::class);
4849
$this->checkoutSessionMock = $this->createMock(Session::class);
4950
$this->addressRepositoryMock = $this->getMockForAbstractClass(AddressRepositoryInterface::class);
51+
$disableMultishippingMock = $this->createMock(DisableMultishipping::class);
5052
$this->model = new CartPlugin(
5153
$this->cartRepositoryMock,
5254
$this->checkoutSessionMock,
53-
$this->addressRepositoryMock
55+
$this->addressRepositoryMock,
56+
$disableMultishippingMock
5457
);
5558
}
5659

@@ -65,33 +68,41 @@ public function testBeforeDispatch()
6568
'getShippingAddress',
6669
'getCustomer'
6770
]);
68-
$this->checkoutSessionMock->expects($this->once())->method('getQuote')->willReturn($quoteMock);
71+
$this->checkoutSessionMock->method('getQuote')
72+
->willReturn($quoteMock);
6973

7074
$addressMock = $this->createMock(Address::class);
71-
$addressMock->expects($this->once())->method('getId')->willReturn($addressId);
75+
$addressMock->method('getId')
76+
->willReturn($addressId);
7277

73-
$quoteMock->expects($this->once())->method('isMultipleShippingAddresses')->willReturn(true);
74-
$quoteMock->expects($this->once())->method('getAllShippingAddresses')->willReturn([$addressMock]);
75-
$quoteMock->expects($this->once())->method('removeAddress')->with($addressId)->willReturnSelf();
78+
$quoteMock->method('isMultipleShippingAddresses')
79+
->willReturn(true);
80+
$quoteMock->method('getAllShippingAddresses')
81+
->willReturn([$addressMock]);
82+
$quoteMock->method('removeAddress')
83+
->with($addressId)->willReturnSelf();
7684

7785
$shippingAddressMock = $this->createMock(Address::class);
78-
$quoteMock->expects($this->once())->method('getShippingAddress')->willReturn($shippingAddressMock);
86+
$quoteMock->method('getShippingAddress')
87+
->willReturn($shippingAddressMock);
7988
$customerMock = $this->getMockForAbstractClass(CustomerInterface::class);
80-
$quoteMock->expects($this->once())->method('getCustomer')->willReturn($customerMock);
81-
$customerMock->expects($this->once())->method('getDefaultShipping')->willReturn($customerAddressId);
89+
$quoteMock->method('getCustomer')
90+
->willReturn($customerMock);
91+
$customerMock->method('getDefaultShipping')
92+
->willReturn($customerAddressId);
8293

8394
$customerAddressMock = $this->getMockForAbstractClass(AddressInterface::class);
84-
$this->addressRepositoryMock->expects($this->once())
85-
->method('getById')
95+
$this->addressRepositoryMock->method('getById')
8696
->with($customerAddressId)
8797
->willReturn($customerAddressMock);
8898

89-
$shippingAddressMock->expects($this->once())
90-
->method('importCustomerAddressData')
99+
$shippingAddressMock->method('importCustomerAddressData')
91100
->with($customerAddressMock)
92101
->willReturnSelf();
93102

94-
$this->cartRepositoryMock->expects($this->once())->method('save')->with($quoteMock);
103+
$this->cartRepositoryMock->expects($this->once())
104+
->method('save')
105+
->with($quoteMock);
95106

96107
$this->model->beforeDispatch(
97108
$this->createMock(Cart::class),

0 commit comments

Comments
 (0)