Skip to content

Commit 3c43aff

Browse files
committed
Merge branch '2.3-develop' into MTF-MFTF-migration-kozan
2 parents 81da262 + 6da226d commit 3c43aff

File tree

35 files changed

+466
-110
lines changed

35 files changed

+466
-110
lines changed

app/code/Magento/Customer/Test/Mftf/Data/AddressData.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@
292292
<item>Piwowarska 6</item>
293293
</array>
294294
<data key="city">Bielsko-Biała</data>
295-
<data key="state"> Bielsko</data>
295+
<data key="state">śląskie</data>
296296
<data key="country_id">PL</data>
297297
<data key="country">Poland</data>
298298
<data key="postcode">43-310</data>

app/code/Magento/Customer/Test/Mftf/Test/AdminCreateCustomerWithCountryPolandTest.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
<click selector="{{AdminCustomerGridSection.firstRowEditLink}}" stepKey="clickOnEditButton"/>
3535
<waitForPageLoad stepKey="waitForCustomerEditPageToLoad"/>
3636

37-
<!--Add the Address -->
37+
<!-- Add the Address -->
3838
<click selector="{{AdminEditCustomerAddressesSection.addresses}}" stepKey="selectAddress"/>
3939
<waitForPageLoad stepKey="waitForAddressPageToLoad"/>
4040
<click selector="{{AdminEditCustomerAddressesSection.addNewAddress}}" stepKey="ClickOnAddNewAddressButton"/>
@@ -44,6 +44,7 @@
4444
<fillField selector="{{AdminEditCustomerAddressesSection.city}}" userInput="{{PolandAddress.city}}" stepKey="fillCity"/>
4545
<scrollTo selector="{{AdminEditCustomerAddressesSection.phone}}" x="0" y="-80" stepKey="scrollToPhone"/>
4646
<selectOption selector="{{AdminEditCustomerAddressesSection.country}}" userInput="{{PolandAddress.country}}" stepKey="fillCountry"/>
47+
<selectOption selector="{{AdminEditCustomerAddressesSection.state}}" userInput="{{PolandAddress.state}}" stepKey="fillState"/>
4748
<fillField selector="{{AdminEditCustomerAddressesSection.zipCode}}" userInput="{{PolandAddress.postcode}}" stepKey="fillPostCode"/>
4849
<fillField selector="{{AdminEditCustomerAddressesSection.phone}}" userInput="{{PolandAddress.telephone}}" stepKey="fillPhoneNumber"/>
4950
<scrollToTopOfPage stepKey="scrollToTopOfPage"/>
@@ -60,6 +61,7 @@
6061
<see userInput="$$createCustomer.firstname$$" selector="{{AdminCustomerGridSection.customerGrid}}" stepKey="assertFirstName"/>
6162
<see userInput="$$createCustomer.lastname$$" selector="{{AdminCustomerGridSection.customerGrid}}" stepKey="assertLastName"/>
6263
<see userInput="$$createCustomer.email$$" selector="{{AdminCustomerGridSection.customerGrid}}" stepKey="assertEmail"/>
64+
<see userInput="{{PolandAddress.state}}" selector="{{AdminCustomerGridSection.customerGrid}}" stepKey="assertState"/>
6365
<see userInput="{{PolandAddress.country}}" selector="{{AdminCustomerGridSection.customerGrid}}" stepKey="assertCountry"/>
6466
<see userInput="{{PolandAddress.postcode}}" selector="{{AdminCustomerGridSection.customerGrid}}" stepKey="assertPostCode"/>
6567
<see userInput="{{PolandAddress.telephone}}" selector="{{AdminCustomerGridSection.customerGrid}}" stepKey="assertPhoneNumber"/>
@@ -86,6 +88,7 @@
8688
<see selector="{{AdminCustomerAddressesGridSection.customerAddressGrid}}" userInput="{{PolandAddress.street}}" stepKey="seeStreetAddress"/>
8789
<see selector="{{AdminCustomerAddressesGridSection.customerAddressGrid}}" userInput="{{PolandAddress.city}}" stepKey="seeCity"/>
8890
<see selector="{{AdminCustomerAddressesGridSection.customerAddressGrid}}" userInput="{{PolandAddress.country}}" stepKey="seeCountry"/>
91+
<see selector="{{AdminCustomerAddressesGridSection.customerAddressGrid}}" userInput="{{PolandAddress.state}}" stepKey="seeState"/>
8992
<see selector="{{AdminCustomerAddressesGridSection.customerAddressGrid}}" userInput="{{PolandAddress.postcode}}" stepKey="seePostCode"/>
9093
<see selector="{{AdminCustomerAddressesGridSection.customerAddressGrid}}" userInput="{{PolandAddress.telephone}}" stepKey="seePhoneNumber"/>
9194
</test>

app/code/Magento/CustomerGraphQl/Model/Customer/Address/CreateCustomerAddress.php

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@
1010
use Magento\Customer\Api\AddressRepositoryInterface;
1111
use Magento\Customer\Api\Data\AddressInterface;
1212
use Magento\Customer\Api\Data\AddressInterfaceFactory;
13+
use Magento\Directory\Helper\Data as DirectoryData;
14+
use Magento\Framework\Api\DataObjectHelper;
1315
use Magento\Framework\Exception\LocalizedException;
1416
use Magento\Framework\GraphQl\Exception\GraphQlInputException;
15-
use Magento\Framework\Api\DataObjectHelper;
1617

1718
/**
1819
* Create customer address
@@ -38,23 +39,30 @@ class CreateCustomerAddress
3839
* @var DataObjectHelper
3940
*/
4041
private $dataObjectHelper;
42+
/**
43+
* @var DirectoryData
44+
*/
45+
private $directoryData;
4146

4247
/**
4348
* @param GetAllowedAddressAttributes $getAllowedAddressAttributes
4449
* @param AddressInterfaceFactory $addressFactory
4550
* @param AddressRepositoryInterface $addressRepository
4651
* @param DataObjectHelper $dataObjectHelper
52+
* @param DirectoryData $directoryData
4753
*/
4854
public function __construct(
4955
GetAllowedAddressAttributes $getAllowedAddressAttributes,
5056
AddressInterfaceFactory $addressFactory,
5157
AddressRepositoryInterface $addressRepository,
52-
DataObjectHelper $dataObjectHelper
58+
DataObjectHelper $dataObjectHelper,
59+
DirectoryData $directoryData
5360
) {
5461
$this->getAllowedAddressAttributes = $getAllowedAddressAttributes;
5562
$this->addressFactory = $addressFactory;
5663
$this->addressRepository = $addressRepository;
5764
$this->dataObjectHelper = $dataObjectHelper;
65+
$this->directoryData = $directoryData;
5866
}
5967

6068
/**
@@ -102,6 +110,13 @@ public function validateData(array $addressData): void
102110
$attributes = $this->getAllowedAddressAttributes->execute();
103111
$errorInput = [];
104112

113+
//Add error for empty postcode with country with no optional ZIP
114+
if (!$this->directoryData->isZipCodeOptional($addressData['country_id'])
115+
&& (!isset($addressData['postcode']) || empty($addressData['postcode']))
116+
) {
117+
$errorInput[] = 'postcode';
118+
}
119+
105120
foreach ($attributes as $attributeName => $attributeInfo) {
106121
if ($attributeInfo->getIsRequired()
107122
&& (!isset($addressData[$attributeName]) || empty($addressData[$attributeName]))

app/code/Magento/CustomerGraphQl/Model/Resolver/DeleteCustomerAddress.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,6 @@ public function resolve(
5858
throw new GraphQlAuthorizationException(__('The current customer isn\'t authorized.'));
5959
}
6060

61-
if (empty($args['id'])) {
62-
throw new GraphQlInputException(__('Address "id" value should be specified'));
63-
}
64-
6561
$address = $this->getCustomerAddress->execute((int)$args['id'], $context->getUserId());
6662
$this->deleteCustomerAddress->execute($address);
6763
return true;

app/code/Magento/CustomerGraphQl/composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
"type": "magento2-module",
55
"require": {
66
"php": "~7.1.3||~7.2.0||~7.3.0",
7-
"magento/module-customer": "*",
87
"magento/module-authorization": "*",
98
"magento/module-customer": "*",
109
"magento/module-eav": "*",
1110
"magento/module-graph-ql": "*",
1211
"magento/module-newsletter": "*",
1312
"magento/module-integration": "*",
1413
"magento/module-store": "*",
15-
"magento/framework": "*"
14+
"magento/framework": "*",
15+
"magento/module-directory": "*"
1616
},
1717
"license": [
1818
"OSL-3.0",
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See PLPYING.txt for license details.
5+
*/
6+
7+
declare(strict_types=1);
8+
9+
namespace Magento\Directory\Setup\Patch\Data;
10+
11+
use Magento\Directory\Setup\DataInstaller;
12+
use Magento\Directory\Setup\DataInstallerFactory;
13+
use Magento\Framework\Setup\ModuleDataSetupInterface;
14+
use Magento\Framework\Setup\Patch\DataPatchInterface;
15+
16+
/**
17+
* Add Poland States
18+
*/
19+
class AddDataForPoland implements DataPatchInterface
20+
{
21+
/**
22+
* @var ModuleDataSetupInterface
23+
*/
24+
private $moduleDataSetup;
25+
26+
/**
27+
* @var DataInstallerFactory
28+
*/
29+
private $dataInstallerFactory;
30+
31+
/**
32+
* @param ModuleDataSetupInterface $moduleDataSetup
33+
* @param DataInstallerFactory $dataInstallerFactory
34+
*/
35+
public function __construct(
36+
ModuleDataSetupInterface $moduleDataSetup,
37+
DataInstallerFactory $dataInstallerFactory
38+
) {
39+
$this->moduleDataSetup = $moduleDataSetup;
40+
$this->dataInstallerFactory = $dataInstallerFactory;
41+
}
42+
43+
/**
44+
* @inheritdoc
45+
*/
46+
public function apply()
47+
{
48+
/** @var DataInstaller $dataInstaller */
49+
$dataInstaller = $this->dataInstallerFactory->create();
50+
$dataInstaller->addCountryRegions(
51+
$this->moduleDataSetup->getConnection(),
52+
$this->getDataForPoland()
53+
);
54+
}
55+
56+
/**
57+
* Poland states data.
58+
*
59+
* @return array
60+
*/
61+
private function getDataForPoland()
62+
{
63+
return [
64+
['PL', 'PL-02', 'dolnośląskie'],
65+
['PL', 'PL-04', 'kujawsko-pomorskie'],
66+
['PL', 'PL-06', 'lubelskie'],
67+
['PL', 'PL-08', 'lubuskie'],
68+
['PL', 'PL-10', 'łódzkie'],
69+
['PL', 'PL-12', 'małopolskie'],
70+
['PL', 'PL-14', 'mazowieckie'],
71+
['PL', 'PL-16', 'opolskie'],
72+
['PL', 'PL-18', 'podkarpackie'],
73+
['PL', 'PL-20', 'podlaskie'],
74+
['PL', 'PL-22', 'pomorskie'],
75+
['PL', 'PL-24', 'śląskie'],
76+
['PL', 'PL-26', 'świętokrzyskie'],
77+
['PL', 'PL-28', 'warmińsko-mazurskie'],
78+
['PL', 'PL-30', 'wielkopolskie'],
79+
['PL', 'PL-32', 'zachodniopomorskie'],
80+
];
81+
}
82+
83+
/**
84+
* @inheritdoc
85+
*/
86+
public static function getDependencies()
87+
{
88+
return [
89+
InitializeDirectoryData::class,
90+
];
91+
}
92+
93+
/**
94+
* @inheritdoc
95+
*/
96+
public function getAliases()
97+
{
98+
return [];
99+
}
100+
}

app/code/Magento/Elasticsearch/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"magento/module-store": "*",
1313
"magento/module-catalog-inventory": "*",
1414
"magento/framework": "*",
15-
"elasticsearch/elasticsearch": "~2.0|~5.1|~6.1"
15+
"elasticsearch/elasticsearch": "~2.0||~5.1||~6.1"
1616
},
1717
"suggest": {
1818
"magento/module-config": "*"

app/code/Magento/Elasticsearch6/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"magento/module-search": "*",
1010
"magento/module-store": "*",
1111
"magento/module-elasticsearch": "*",
12-
"elasticsearch/elasticsearch": "~2.0|~5.1|~6.1"
12+
"elasticsearch/elasticsearch": "~2.0||~5.1||~6.1"
1313
},
1414
"suggest": {
1515
"magento/module-config": "*"

app/code/Magento/QuoteGraphQl/Model/Cart/AddProductsToCart.php

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
namespace Magento\QuoteGraphQl\Model\Cart;
99

1010
use Magento\Framework\GraphQl\Exception\GraphQlInputException;
11-
use Magento\Framework\Message\AbstractMessage;
11+
use Magento\Framework\Message\MessageInterface;
1212
use Magento\Quote\Api\CartRepositoryInterface;
1313
use Magento\Quote\Model\Quote;
1414

@@ -55,29 +55,15 @@ public function execute(Quote $cart, array $cartItems): void
5555
}
5656

5757
if ($cart->getData('has_error')) {
58-
throw new GraphQlInputException(
59-
__('Shopping cart error: %message', ['message' => $this->getCartErrors($cart)])
60-
);
58+
$e = new GraphQlInputException(__('Shopping cart errors'));
59+
$errors = $cart->getErrors();
60+
foreach ($errors as $error) {
61+
/** @var MessageInterface $error */
62+
$e->addError(new GraphQlInputException(__($error->getText())));
63+
}
64+
throw $e;
6165
}
6266

6367
$this->cartRepository->save($cart);
6468
}
65-
66-
/**
67-
* Collecting cart errors
68-
*
69-
* @param Quote $cart
70-
* @return string
71-
*/
72-
private function getCartErrors(Quote $cart): string
73-
{
74-
$errorMessages = [];
75-
76-
/** @var AbstractMessage $error */
77-
foreach ($cart->getErrors() as $error) {
78-
$errorMessages[] = $error->getText();
79-
}
80-
81-
return implode(PHP_EOL, $errorMessages);
82-
}
8369
}

app/code/Magento/QuoteGraphQl/Model/Cart/AddSimpleProductToCart.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,12 @@ public function execute(Quote $cart, array $cartItemData): void
7272
}
7373

7474
if (is_string($result)) {
75-
throw new GraphQlInputException(__($result));
75+
$e = new GraphQlInputException(__('Cannot add product to cart'));
76+
$errors = array_unique(explode("\n", $result));
77+
foreach ($errors as $error) {
78+
$e->addError(new GraphQlInputException(__($error)));
79+
}
80+
throw $e;
7681
}
7782
}
7883

0 commit comments

Comments
 (0)