Skip to content

Commit a9a0f95

Browse files
committed
Merge remote-tracking branch 'origin/2.4-develop' into L3-PR-20210324
2 parents fdcee4f + a369628 commit a9a0f95

File tree

29 files changed

+1594
-497
lines changed

29 files changed

+1594
-497
lines changed

app/code/Magento/BundleImportExport/Model/Import/Product/Type/Bundle.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -573,8 +573,12 @@ protected function insertOptions()
573573

574574
$optionIds = $this->connection->fetchAssoc(
575575
$this->connection->select()->from(
576-
$this->_resource->getTableName('catalog_product_bundle_option'),
576+
['bo' => $this->_resource->getTableName('catalog_product_bundle_option')],
577577
['option_id', 'position', 'parent_id']
578+
)->joinLeft(
579+
['bov' => $this->_resource->getTableName('catalog_product_bundle_option_value')],
580+
'bo.option_id = bov.option_id',
581+
['title']
578582
)->where(
579583
'parent_id IN (?)',
580584
$productIds
@@ -600,8 +604,10 @@ protected function populateInsertOptionValues(array $optionIds): array
600604
foreach ($this->_cachedOptions as $entityId => $options) {
601605
foreach ($options as $key => $option) {
602606
foreach ($optionIds as $optionId => $assoc) {
603-
if ($assoc['position'] == $this->_cachedOptions[$entityId][$key]['index']
604-
&& $assoc['parent_id'] == $entityId) {
607+
if ($assoc['position'] == $this->_cachedOptions[$entityId][$key]['index'] &&
608+
$assoc['parent_id'] == $entityId &&
609+
(empty($assoc['title']) || $assoc['title'] == $this->_cachedOptions[$entityId][$key]['name'])
610+
) {
605611
$option['parent_id'] = $entityId;
606612
$optionValues[] = $this->populateOptionValueTemplate($option, $optionId);
607613
$this->_cachedOptions[$entityId][$key]['option_id'] = $optionId;

app/code/Magento/BundleImportExport/Test/Unit/Model/Import/Product/Type/BundleTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,7 @@ public function testSaveData($skus, $bunch, $allowImport)
289289
'type' => 'bundle',
290290
'value_id' => '6',
291291
'title' => 'Bundle6',
292+
'name' => 'Bundle6',
292293
'selections' => [
293294
[
294295
'name' => 'Bundlen6',

app/code/Magento/CatalogGraphQl/Model/Resolver/Products/DataProvider/ExtractDataFromCategoryTree.php

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ public function execute(\Iterator $iterator): array
6767
$tree = $this->mergeCategoriesTrees($currentLevelTree, $tree);
6868
}
6969
}
70-
return $tree;
70+
71+
return $this->sortTree($tree);
7172
}
7273

7374
/**
@@ -141,4 +142,24 @@ private function explodePathToArray(array $pathElements, int $index): array
141142
}
142143
return $tree;
143144
}
145+
146+
/**
147+
* Recursive method to sort tree
148+
*
149+
* @param array $tree
150+
* @return array
151+
*/
152+
private function sortTree(array $tree): array
153+
{
154+
foreach ($tree as &$node) {
155+
if ($node['children']) {
156+
uasort($node['children'], function ($element1, $element2) {
157+
return $element1['position'] > $element2['position'];
158+
});
159+
$node['children'] = $this->sortTree($node['children']);
160+
}
161+
}
162+
163+
return $tree;
164+
}
144165
}

app/code/Magento/Checkout/Model/DefaultConfigProvider.php

Lines changed: 44 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Magento\Checkout\Model\Session as CheckoutSession;
1212
use Magento\Customer\Api\AddressMetadataInterface;
1313
use Magento\Customer\Api\CustomerRepositoryInterface as CustomerRepository;
14+
use Magento\Customer\Api\Data\CustomerInterface;
1415
use Magento\Customer\Model\Address\CustomerAddressDataProvider;
1516
use Magento\Customer\Model\Context as CustomerContext;
1617
use Magento\Customer\Model\Session as CustomerSession;
@@ -311,14 +312,11 @@ public function getConfig()
311312
$output['isCustomerLoggedIn'] = $this->isCustomerLoggedIn();
312313
$output['selectedShippingMethod'] = $this->getSelectedShippingMethod();
313314
if ($email && !$this->isCustomerLoggedIn()) {
314-
$shippingAddressFromData = $this->getAddressFromData($quote->getShippingAddress());
315-
$billingAddressFromData = $this->getAddressFromData($quote->getBillingAddress());
316-
$output['shippingAddressFromData'] = $shippingAddressFromData;
317-
if ($shippingAddressFromData != $billingAddressFromData) {
318-
$output['billingAddressFromData'] = $billingAddressFromData;
319-
}
320315
$output['validatedEmailValue'] = $email;
321316
}
317+
if (!$this->isCustomerLoggedIn() || !$this->getCustomer()->getAddresses()) {
318+
$output = array_merge($output, $this->getQuoteAddressData());
319+
}
322320
$output['storeCode'] = $this->getStoreCode();
323321
$output['isGuestCheckoutAllowed'] = $this->isGuestCheckoutAllowed();
324322
$output['isCustomerLoginRequired'] = $this->isCustomerLoginRequired();
@@ -387,8 +385,7 @@ private function getCustomerData(): array
387385
{
388386
$customerData = [];
389387
if ($this->isCustomerLoggedIn()) {
390-
/** @var \Magento\Customer\Api\Data\CustomerInterface $customer */
391-
$customer = $this->customerRepository->getById($this->customerSession->getCustomerId());
388+
$customer = $this->getCustomer();
392389
$customerData = $customer->__toArray();
393390
$customerData['addresses'] = $this->customerAddressData->getAddressDataByCustomer($customer);
394391
}
@@ -731,4 +728,43 @@ private function getQuoteItemsMessages(array $quoteItemData): array
731728

732729
return $quoteItemsMessages;
733730
}
731+
732+
/**
733+
* Get quote address data for checkout
734+
*
735+
* @return array
736+
*/
737+
private function getQuoteAddressData(): array
738+
{
739+
$output = [];
740+
$quote = $this->checkoutSession->getQuote();
741+
$shippingAddressFromData = [];
742+
if ($quote->getShippingAddress()->getEmail()) {
743+
$shippingAddressFromData = $this->getAddressFromData($quote->getShippingAddress());
744+
if ($shippingAddressFromData) {
745+
$output['isShippingAddressFromDataValid'] = $quote->getShippingAddress()->validate() === true;
746+
$output['shippingAddressFromData'] = $shippingAddressFromData;
747+
}
748+
}
749+
750+
if ($quote->getBillingAddress()->getEmail()) {
751+
$billingAddressFromData = $this->getAddressFromData($quote->getBillingAddress());
752+
if ($billingAddressFromData && $shippingAddressFromData != $billingAddressFromData) {
753+
$output['isBillingAddressFromDataValid'] = $quote->getBillingAddress()->validate() === true;
754+
$output['billingAddressFromData'] = $billingAddressFromData;
755+
}
756+
}
757+
758+
return $output;
759+
}
760+
761+
/**
762+
* Get logged-in customer
763+
*
764+
* @return CustomerInterface
765+
*/
766+
private function getCustomer(): CustomerInterface
767+
{
768+
return $this->customerRepository->getById($this->customerSession->getCustomerId());
769+
}
734770
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
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+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="AssertStorefrontGuestCheckoutShippingAddressFormPrefilledActionGroup">
12+
<annotations>
13+
<description>Verify that shipping address form is filled with provided customer and address information.</description>
14+
</annotations>
15+
<arguments>
16+
<argument name="customer" defaultValue="Simple_US_Customer" type="entity"/>
17+
<argument name="address" defaultValue="US_Address_TX" type="entity"/>
18+
</arguments>
19+
20+
<grabValueFrom selector="{{CheckoutShippingSection.email}}" stepKey="email"/>
21+
<grabValueFrom selector="{{CheckoutShippingSection.firstName}}" stepKey="firstname"/>
22+
<grabValueFrom selector="{{CheckoutShippingSection.lastName}}" stepKey="lastname"/>
23+
<grabValueFrom selector="{{CheckoutShippingSection.street}}" stepKey="street"/>
24+
<grabValueFrom selector="{{CheckoutShippingSection.city}}" stepKey="city"/>
25+
<grabValueFrom selector="{{CheckoutShippingSection.postcode}}" stepKey="postcode"/>
26+
<grabValueFrom selector="{{CheckoutShippingSection.telephone}}" stepKey="telephone"/>
27+
28+
<assertEquals stepKey="assertEmail">
29+
<actualResult type="variable">email</actualResult>
30+
<expectedResult type="string">{{customer.email}}</expectedResult>
31+
</assertEquals>
32+
<assertEquals stepKey="assertFirstName">
33+
<actualResult type="variable">firstname</actualResult>
34+
<expectedResult type="string">{{customer.firstName}}</expectedResult>
35+
</assertEquals>
36+
<assertEquals stepKey="assertLastName">
37+
<actualResult type="variable">lastname</actualResult>
38+
<expectedResult type="string">{{customer.lastName}}</expectedResult>
39+
</assertEquals>
40+
<assertEquals stepKey="assertStreet">
41+
<actualResult type="variable">street</actualResult>
42+
<expectedResult type="string">{{address.street[0]}}</expectedResult>
43+
</assertEquals>
44+
<assertEquals stepKey="assertCity">
45+
<actualResult type="variable">city</actualResult>
46+
<expectedResult type="string">{{address.city}}</expectedResult>
47+
</assertEquals>
48+
<seeOptionIsSelected selector="{{CheckoutShippingSection.region}}" userInput="{{address.state}}" stepKey="assertRegion"/>
49+
<seeOptionIsSelected selector="{{CheckoutShippingSection.country}}" userInput="{{address.country}}" stepKey="assertCountry"/>
50+
<assertEquals stepKey="assertPostcode">
51+
<actualResult type="variable">postcode</actualResult>
52+
<expectedResult type="string">{{address.postcode}}</expectedResult>
53+
</assertEquals>
54+
<assertEquals stepKey="assertTelephone">
55+
<actualResult type="variable">telephone</actualResult>
56+
<expectedResult type="string">{{address.telephone}}</expectedResult>
57+
</assertEquals>
58+
</actionGroup>
59+
</actionGroups>
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+
9+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="FillGuestCheckoutShippingAddressWithCountryAndStateActionGroup" extends="FillGuestCheckoutShippingAddressFormActionGroup">
12+
<selectOption selector="{{CheckoutShippingSection.country}}" userInput="{{customerAddress.country_id}}" after="SetCustomerCity" stepKey="selectCustomerCountry"/>
13+
<selectOption selector="{{CheckoutShippingSection.region}}" userInput="{{customerAddress.state}}" after="selectCustomerCountry" stepKey="SetCustomerState"/>
14+
</actionGroup>
15+
</actionGroups>

0 commit comments

Comments
 (0)