Skip to content

Commit fb5dc9d

Browse files
[Magento Community Engineering] Community Contributions - 2.3-develop
- merged latest code from mainline branch
2 parents 32bc3be + e2ac8c8 commit fb5dc9d

File tree

41 files changed

+1319
-173
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1319
-173
lines changed

app/code/Magento/Backend/view/adminhtml/templates/widget/grid.phtml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,9 @@ $numColumns = $block->getColumns() !== null ? count($block->getColumns()) : 0;
170170
<?php if ($block->getSortableUpdateCallback()) : ?>
171171
<?= $block->escapeJs($block->getJsObjectName()) ?>.sortableUpdateCallback = <?= /* @noEscape */ $block->getSortableUpdateCallback() ?>;
172172
<?php endif; ?>
173+
<?php if ($block->getFilterKeyPressCallback()) : ?>
174+
<?= $block->escapeJs($block->getJsObjectName()) ?>.filterKeyPressCallback = <?= /* @noEscape */ $block->getFilterKeyPressCallback() ?>;
175+
<?php endif; ?>
173176
<?= $block->escapeJs($block->getJsObjectName()) ?>.bindSortable();
174177
<?php if ($block->getRowInitCallback()) : ?>
175178
<?= $block->escapeJs($block->getJsObjectName()) ?>.initRowCallback = <?= /* @noEscape */ $block->getRowInitCallback() ?>;

app/code/Magento/Backend/view/adminhtml/templates/widget/grid/extended.phtml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,9 @@ $numColumns = count($block->getColumns());
272272
<?php if ($block->getCheckboxCheckCallback()) : ?>
273273
<?= $block->escapeJs($block->getJsObjectName()) ?>.checkboxCheckCallback = <?= /* @noEscape */ $block->getCheckboxCheckCallback() ?>;
274274
<?php endif; ?>
275+
<?php if ($block->getFilterKeyPressCallback()) : ?>
276+
<?= $block->escapeJs($block->getJsObjectName()) ?>.filterKeyPressCallback = <?= /* @noEscape */ $block->getFilterKeyPressCallback() ?>;
277+
<?php endif; ?>
275278
<?php if ($block->getRowInitCallback()) : ?>
276279
<?= $block->escapeJs($block->getJsObjectName()) ?>.initRowCallback = <?= /* @noEscape */ $block->getRowInitCallback() ?>;
277280
<?= $block->escapeJs($block->getJsObjectName()) ?>.initGridRows();

app/code/Magento/Braintree/Gateway/Validator/ErrorCodeProvider.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Braintree\Error\Validation;
1212
use Braintree\Result\Error;
1313
use Braintree\Result\Successful;
14+
use Braintree\Transaction;
1415

1516
/**
1617
* Processes errors codes from Braintree response.
@@ -38,12 +39,14 @@ public function getErrorCodes($response): array
3839
$result[] = $error->code;
3940
}
4041

41-
if (isset($response->transaction) && $response->transaction->status === 'gateway_rejected') {
42-
$result[] = $response->transaction->gatewayRejectionReason;
43-
}
42+
if (isset($response->transaction) && $response->transaction) {
43+
if ($response->transaction->status === Transaction::GATEWAY_REJECTED) {
44+
$result[] = $response->transaction->gatewayRejectionReason;
45+
}
4446

45-
if (isset($response->transaction) && $response->transaction->status === 'processor_declined') {
46-
$result[] = $response->transaction->processorResponseCode;
47+
if ($response->transaction->status === Transaction::PROCESSOR_DECLINED) {
48+
$result[] = $response->transaction->processorResponseCode;
49+
}
4750
}
4851

4952
return $result;
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Catalog\Model\Product;
9+
10+
use Magento\Framework\EntityManager\HydratorInterface;
11+
12+
/**
13+
* Class is used to extract data and populate entity with data
14+
*/
15+
class Hydrator implements HydratorInterface
16+
{
17+
/**
18+
* @inheritdoc
19+
*/
20+
public function extract($entity)
21+
{
22+
return $entity->getData();
23+
}
24+
25+
/**
26+
* @inheritdoc
27+
*/
28+
public function hydrate($entity, array $data)
29+
{
30+
$lockedAttributes = $entity->getLockedAttributes();
31+
$entity->unlockAttributes();
32+
$entity->setData(array_merge($entity->getData(), $data));
33+
foreach ($lockedAttributes as $attribute) {
34+
$entity->lockAttribute($attribute);
35+
}
36+
37+
return $entity;
38+
}
39+
}

app/code/Magento/Catalog/etc/di.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -867,7 +867,7 @@
867867
<argument name="hydrators" xsi:type="array">
868868
<item name="Magento\Catalog\Api\Data\CategoryInterface" xsi:type="string">Magento\Framework\EntityManager\AbstractModelHydrator</item>
869869
<item name="Magento\Catalog\Api\Data\CategoryTreeInterface" xsi:type="string">Magento\Framework\EntityManager\AbstractModelHydrator</item>
870-
<item name="Magento\Catalog\Api\Data\ProductInterface" xsi:type="string">Magento\Framework\EntityManager\AbstractModelHydrator</item>
870+
<item name="Magento\Catalog\Api\Data\ProductInterface" xsi:type="string">Magento\Catalog\Model\Product\Hydrator</item>
871871
</argument>
872872
</arguments>
873873
</type>

app/code/Magento/Checkout/view/frontend/web/js/model/address-converter.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ define([
99
'jquery',
1010
'Magento_Checkout/js/model/new-customer-address',
1111
'Magento_Customer/js/customer-data',
12-
'mage/utils/objects'
13-
], function ($, address, customerData, mageUtils) {
12+
'mage/utils/objects',
13+
'underscore'
14+
], function ($, address, customerData, mageUtils, _) {
1415
'use strict';
1516

1617
var countryData = customerData.get('directory-data');
@@ -60,13 +61,15 @@ define([
6061
delete addressData['region_id'];
6162

6263
if (addressData['custom_attributes']) {
63-
addressData['custom_attributes'] = Object.entries(addressData['custom_attributes'])
64-
.map(function (customAttribute) {
64+
addressData['custom_attributes'] = _.map(
65+
addressData['custom_attributes'],
66+
function (value, key) {
6567
return {
66-
'attribute_code': customAttribute[0],
67-
'value': customAttribute[1]
68+
'attribute_code': key,
69+
'value': value
6870
};
69-
});
71+
}
72+
);
7073
}
7174

7275
return address(addressData);

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

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,21 @@
254254
<data key="state">Côtes-d'Armor</data>
255255
<data key="postcode">12345</data>
256256
</entity>
257+
<entity name="updateCustomerChinaAddress" type="address">
258+
<data key="firstname">Xian</data>
259+
<data key="lastname">Shai</data>
260+
<data key="company">Hunan Fenmian</data>
261+
<data key="telephone">+86 851 8410 4337</data>
262+
<array key="street">
263+
<item>Nanyuan Rd, Wudang</item>
264+
<item>Hunan Fenmian</item>
265+
</array>
266+
<data key="country_id">CN</data>
267+
<data key="country">China</data>
268+
<data key="city">Guiyang</data>
269+
<data key="state">Guizhou Sheng</data>
270+
<data key="postcode">550002</data>
271+
</entity>
257272
<entity name="updateCustomerNoXSSInjection" type="address">
258273
<data key="firstname">Jany</data>
259274
<data key="lastname">Doe</data>
@@ -345,4 +360,19 @@
345360
<data key="default_shipping">Yes</data>
346361
<requiredEntity type="region">RegionAE</requiredEntity>
347362
</entity>
363+
<entity name="updateCustomerBelgiumAddress" type="address">
364+
<data key="firstname">John</data>
365+
<data key="lastname">Doe</data>
366+
<data key="company">Magento</data>
367+
<array key="street">
368+
<item>Chaussee de Wavre</item>
369+
<item>318</item>
370+
</array>
371+
<data key="city">Bihain</data>
372+
<data key="state">Hainaut</data>
373+
<data key="country_id">BE</data>
374+
<data key="country">Belgium</data>
375+
<data key="postcode">6690</data>
376+
<data key="telephone">0477-58-77867</data>
377+
</entity>
348378
</entities>
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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="StorefrontUpdateCustomerAddressBelgiumTest">
12+
<annotations>
13+
<stories value="Update Regions list for Belgium country"/>
14+
<title value="Update customer address on storefront with Belgium address"/>
15+
<description value="Update customer address on storefront with Belgium address and verify you can select a region"/>
16+
<testCaseId value="MC-20234"/>
17+
<severity value="AVERAGE"/>
18+
<group value="customer"/>
19+
</annotations>
20+
21+
<before>
22+
<actionGroup ref = "LoginAsAdmin" stepKey="loginAsAdmin"/>
23+
<actionGroup ref="SignUpNewUserFromStorefrontActionGroup" stepKey="SignUpNewUser">
24+
<argument name="Customer" value="CustomerEntityOne"/>
25+
</actionGroup>
26+
</before>
27+
<after>
28+
<actionGroup ref="DeleteCustomerByEmailActionGroup" stepKey="deleteNewUser">
29+
<argument name="email" value="{{CustomerEntityOne.email}}"/>
30+
</actionGroup>
31+
<actionGroup ref="logout" stepKey="logout"/>
32+
</after>
33+
34+
<!--Update customer address Belgium in storefront-->
35+
<actionGroup ref="EnterCustomerAddressInfo" stepKey="enterAddress">
36+
<argument name="Address" value="updateCustomerBelgiumAddress"/>
37+
</actionGroup>
38+
<!--Verify customer address save success message-->
39+
<see selector="{{AdminCustomerMessagesSection.successMessage}}" userInput="You saved the address." stepKey="seeAssertCustomerAddressSuccessSaveMessage"/>
40+
41+
<!--Verify customer default billing address-->
42+
<actionGroup ref="VerifyCustomerBillingAddressWithState" stepKey="verifyBillingAddress">
43+
<argument name="address" value="updateCustomerBelgiumAddress"/>
44+
</actionGroup>
45+
46+
<!--Verify customer default shipping address-->
47+
<actionGroup ref="VerifyCustomerShippingAddressWithState" stepKey="verifyShippingAddress">
48+
<argument name="address" value="updateCustomerBelgiumAddress"/>
49+
</actionGroup>
50+
</test>
51+
</tests>
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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="StorefrontUpdateCustomerAddressChinaTest">
12+
<annotations>
13+
<stories value="Update Regions list for China country"/>
14+
<title value="Update customer address on storefront with china address"/>
15+
<description value="Update customer address on storefront with china address and verify you can select a region"/>
16+
<testCaseId value="MC-20234"/>
17+
<severity value="AVERAGE"/>
18+
<group value="customer"/>
19+
</annotations>
20+
21+
<before>
22+
<actionGroup ref = "LoginAsAdmin" stepKey="loginAsAdmin"/>
23+
<actionGroup ref="SignUpNewUserFromStorefrontActionGroup" stepKey="SignUpNewUser">
24+
<argument name="Customer" value="CustomerEntityOne"/>
25+
</actionGroup>
26+
</before>
27+
<after>
28+
<actionGroup ref="DeleteCustomerByEmailActionGroup" stepKey="deleteNewUser">
29+
<argument name="email" value="{{CustomerEntityOne.email}}"/>
30+
</actionGroup>
31+
<actionGroup ref="logout" stepKey="logout"/>
32+
</after>
33+
34+
<!--Update customer address in storefront-->
35+
<actionGroup ref="EnterCustomerAddressInfo" stepKey="enterAddress">
36+
<argument name="Address" value="updateCustomerChinaAddress"/>
37+
</actionGroup>
38+
<!--Verify customer address save success message-->
39+
<see selector="{{AdminCustomerMessagesSection.successMessage}}" userInput="You saved the address." stepKey="seeAssertCustomerAddressSuccessSaveMessage"/>
40+
41+
<!--Verify customer default billing address-->
42+
<actionGroup ref="VerifyCustomerBillingAddressWithState" stepKey="verifyBillingAddress">
43+
<argument name="address" value="updateCustomerChinaAddress"/>
44+
</actionGroup>
45+
46+
<!--Verify customer default shipping address-->
47+
<actionGroup ref="VerifyCustomerShippingAddressWithState" stepKey="verifyShippingAddress">
48+
<argument name="address" value="updateCustomerChinaAddress"/>
49+
</actionGroup>
50+
</test>
51+
</tests>
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Directory\Setup\Patch\Data;
8+
9+
use Magento\Directory\Setup\DataInstaller;
10+
use Magento\Framework\Setup\ModuleDataSetupInterface;
11+
use Magento\Framework\Setup\Patch\DataPatchInterface;
12+
13+
/**
14+
* Add Regions for Belgium.
15+
*/
16+
class AddDataForBelgium implements DataPatchInterface
17+
{
18+
/**
19+
* @var ModuleDataSetupInterface
20+
*/
21+
private $moduleDataSetup;
22+
23+
/**
24+
* @var \Magento\Directory\Setup\DataInstallerFactory
25+
*/
26+
private $dataInstallerFactory;
27+
28+
/**
29+
* @param ModuleDataSetupInterface $moduleDataSetup
30+
* @param \Magento\Directory\Setup\DataInstallerFactory $dataInstallerFactory
31+
*/
32+
public function __construct(
33+
ModuleDataSetupInterface $moduleDataSetup,
34+
\Magento\Directory\Setup\DataInstallerFactory $dataInstallerFactory
35+
) {
36+
$this->moduleDataSetup = $moduleDataSetup;
37+
$this->dataInstallerFactory = $dataInstallerFactory;
38+
}
39+
40+
/**
41+
* @inheritdoc
42+
*/
43+
public function apply()
44+
{
45+
/** @var DataInstaller $dataInstaller */
46+
$dataInstaller = $this->dataInstallerFactory->create();
47+
$dataInstaller->addCountryRegions(
48+
$this->moduleDataSetup->getConnection(),
49+
$this->getDataForBelgium()
50+
);
51+
}
52+
53+
/**
54+
* Belgium states data.
55+
*
56+
* @return array
57+
*/
58+
private function getDataForBelgium()
59+
{
60+
return [
61+
['BE', 'VAN', 'Antwerpen'],
62+
['BE', 'WBR', 'Brabant wallon'],
63+
['BE', 'BRU', 'Brussels Hoofdstedelijk Gewest'],
64+
['BE', 'WHT', 'Hainaut'],
65+
['BE', 'VLI', 'Limburg'],
66+
['BE', 'WLG', 'Liege'],
67+
['BE', 'WLX', 'Luxembourg'],
68+
['BE', 'WNA', 'Namur'],
69+
['BE', 'VOV', 'Oost-Vlaanderen'],
70+
['BE', 'VLG', 'Vlaams Gewest'],
71+
['BE', 'VBR', 'Vlaams-Brabant'],
72+
['BE', 'VWV', 'West-Vlaanderen'],
73+
['BE', 'WAL', 'Wallonne, Region']
74+
];
75+
}
76+
77+
/**
78+
* @inheritdoc
79+
*/
80+
public static function getDependencies()
81+
{
82+
return [
83+
InitializeDirectoryData::class,
84+
];
85+
}
86+
87+
/**
88+
* @inheritdoc
89+
*/
90+
public function getAliases()
91+
{
92+
return [];
93+
}
94+
}

0 commit comments

Comments
 (0)