Skip to content

Commit 7f0b76e

Browse files
committed
Merge remote-tracking branch 'performance-ce/order-convert' into MCP-767
# Conflicts: # lib/internal/Magento/Framework/Api/DataObjectHelper.php
2 parents a145592 + 4790278 commit 7f0b76e

File tree

95 files changed

+4898
-2134
lines changed

Some content is hidden

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

95 files changed

+4898
-2134
lines changed

app/code/Magento/Backend/Block/Widget/Grid/Column.php

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
67
namespace Magento\Backend\Block\Widget\Grid;
78

89
use Magento\Backend\Block\Widget;
@@ -46,7 +47,7 @@ class Column extends Widget
4647
protected $_cssClass = null;
4748

4849
/**
49-
* Renderer types
50+
* The renderer types
5051
*
5152
* @var array
5253
*/
@@ -74,7 +75,7 @@ class Column extends Widget
7475
];
7576

7677
/**
77-
* Filter types
78+
* The filter types
7879
*
7980
* @var array
8081
*/
@@ -103,6 +104,8 @@ class Column extends Widget
103104
protected $_isGrouped = false;
104105

105106
/**
107+
* Set property is grouped.
108+
*
106109
* @return void
107110
*/
108111
public function _construct()
@@ -169,7 +172,8 @@ public function getHtmlProperty()
169172
}
170173

171174
/**
172-
* Get Header html
175+
* This method get Header html.
176+
*
173177
* @return string
174178
*/
175179
public function getHeaderHtml()
@@ -222,7 +226,8 @@ public function setSortable($value)
222226
}
223227

224228
/**
225-
* Get header css class name
229+
* Get header css class name.
230+
*
226231
* @return string
227232
*/
228233
public function getHeaderCssClass()
@@ -234,6 +239,8 @@ public function getHeaderCssClass()
234239
}
235240

236241
/**
242+
* This method check if is sortable.
243+
*
237244
* @return bool
238245
* @SuppressWarnings(PHPMD.BooleanGetMethodName)
239246
*/
@@ -256,6 +263,7 @@ public function addHeaderCssClass($className)
256263

257264
/**
258265
* Get header class names
266+
*
259267
* @return string
260268
*/
261269
public function getHeaderHtmlProperty()
@@ -291,6 +299,7 @@ public function getRowField(\Magento\Framework\DataObject $row)
291299
$frameCallback = $this->getFrameCallback();
292300
if (is_array($frameCallback)) {
293301
$this->validateFrameCallback($frameCallback);
302+
//phpcs:ignore Magento2.Functions.DiscouragedFunction
294303
$renderedValue = call_user_func($frameCallback, $renderedValue, $row, $this, false);
295304
}
296305

@@ -334,6 +343,7 @@ public function getRowFieldExport(\Magento\Framework\DataObject $row)
334343
$frameCallback = $this->getFrameCallback();
335344
if (is_array($frameCallback)) {
336345
$this->validateFrameCallback($frameCallback);
346+
//phpcs:ignore Magento2.Functions.DiscouragedFunction
337347
$renderedValue = call_user_func($frameCallback, $renderedValue, $row, $this, true);
338348
}
339349

@@ -412,12 +422,8 @@ public function setRendererType($type, $className)
412422
*/
413423
protected function _getRendererByType()
414424
{
415-
$type = strtolower($this->getType());
416-
$rendererClass = isset(
417-
$this->_rendererTypes[$type]
418-
) ? $this->_rendererTypes[$type] : $this->_rendererTypes['default'];
419-
420-
return $rendererClass;
425+
$type = strtolower((string) $this->getType());
426+
return $this->_rendererTypes[$type] ?? $this->_rendererTypes['default'];
421427
}
422428

423429
/**
@@ -469,10 +475,8 @@ public function setFilterType($type, $className)
469475
*/
470476
protected function _getFilterByType()
471477
{
472-
$type = $this->getFilterType() ? strtolower($this->getFilterType()) : strtolower($this->getType());
473-
$filterClass = isset($this->_filterTypes[$type]) ? $this->_filterTypes[$type] : $this->_filterTypes['default'];
474-
475-
return $filterClass;
478+
$type = $this->getFilterType() ? strtolower($this->getFilterType()) : strtolower((string) $this->getType());
479+
return $this->_filterTypes[$type] ?? $this->_filterTypes['default'];
476480
}
477481

478482
/**

app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Date.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ protected function _convertDate($date)
233233
\IntlDateFormatter::NONE,
234234
$adminTimeZone
235235
);
236-
$simpleRes = new \DateTime(null, $adminTimeZone);
236+
$simpleRes = new \DateTime('now', $adminTimeZone);
237237
$simpleRes->setTimestamp($formatter->parse($date));
238238
$simpleRes->setTime(0, 0, 0);
239239
$simpleRes->setTimezone(new \DateTimeZone('UTC'));

app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Concat.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,12 @@ public function render(\Magento\Framework\DataObject $row)
3030
&& is_callable([$row, $method])
3131
&& substr_compare('get', $method, 1, 3) !== 0
3232
) {
33+
//phpcs:ignore Magento2.Functions.DiscouragedFunction
3334
$data = call_user_func([$row, $method]);
3435
} else {
3536
$data = $row->getData($method);
3637
}
37-
if (strlen($data) > 0) {
38+
if (strlen((string) $data) > 0) {
3839
$dataArr[] = $data;
3940
}
4041
}

app/code/Magento/Bundle/Model/Option/Validator.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@ public function __construct(NotEmptyFactory $notEmptyFactory)
2626
}
2727

2828
/**
29+
* This method check is valid value.
30+
*
2931
* @param \Magento\Bundle\Model\Option $value
32+
*
3033
* @return boolean
3134
* @throws Zend_Validate_Exception If validation of $value is impossible
3235
*/
@@ -38,10 +41,12 @@ public function isValid($value)
3841
}
3942

4043
/**
44+
* This method validate required fields.
45+
*
4146
* @param \Magento\Bundle\Model\Option $value
47+
*
4248
* @return void
43-
* @throws Zend_Validate_Exception
44-
* @throws \Exception
49+
* @throws \Exception|Zend_Validate_Exception
4550
*/
4651
protected function validateRequiredFields($value)
4752
{
@@ -51,7 +56,7 @@ protected function validateRequiredFields($value)
5156
'type' => $value->getType()
5257
];
5358
foreach ($requiredFields as $requiredField => $requiredValue) {
54-
if (!$this->notEmpty->isValid(trim($requiredValue))) {
59+
if (!$this->notEmpty->isValid(trim((string) $requiredValue))) {
5560
$messages[$requiredField] =
5661
__('"%fieldName" is required. Enter and try again.', ['fieldName' => $requiredField]);
5762
}

app/code/Magento/CatalogGraphQl/DataProvider/Product/SearchCriteriaBuilder.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public function build(array $args, bool $includeAggregation): SearchCriteriaInte
104104
$this->addDefaultSortOrder($searchCriteria, $args, $isSearch);
105105
}
106106

107-
$this->addEntityIdSort($searchCriteria, $isSearch);
107+
$this->addEntityIdSort($searchCriteria, $args);
108108
$this->addVisibilityFilter($searchCriteria, $isSearch, !empty($args['filter']));
109109

110110
$searchCriteria->setCurrentPage($args['currentPage']);
@@ -137,17 +137,15 @@ private function addVisibilityFilter(SearchCriteriaInterface $searchCriteria, bo
137137
* Add sort by Entity ID
138138
*
139139
* @param SearchCriteriaInterface $searchCriteria
140-
* @param bool $isSearch
140+
* @param array $args
141141
*/
142-
private function addEntityIdSort(SearchCriteriaInterface $searchCriteria, bool $isSearch): void
142+
private function addEntityIdSort(SearchCriteriaInterface $searchCriteria, array $args): void
143143
{
144-
if ($isSearch) {
145-
return;
146-
}
144+
$sortOrder = !empty($args['sort']) ? reset($args['sort']) : SortOrder::SORT_DESC;
147145
$sortOrderArray = $searchCriteria->getSortOrders();
148146
$sortOrderArray[] = $this->sortOrderBuilder
149147
->setField('_id')
150-
->setDirection(SortOrder::SORT_DESC)
148+
->setDirection($sortOrder)
151149
->create();
152150
$searchCriteria->setSortOrders($sortOrderArray);
153151
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
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="StorefrontAddressDeletedStreetAddressRemainsEmptyAfterRefreshTest">
12+
<annotations>
13+
<features value="Checkout"/>
14+
<stories value="Guest checkout"/>
15+
<title value="Address Street Field Remain Empty when deleted even After Browser Refresh"/>
16+
<description value="Address Street Field Remain Empty when deleted even After Browser Refresh"/>
17+
<severity value="MINOR"/>
18+
<testCaseId value="MC-43255"/>
19+
<group value="checkout"/>
20+
</annotations>
21+
<before>
22+
<createData entity="simpleProductWithoutCategory" stepKey="createSimpleProduct"/>
23+
</before>
24+
<after>
25+
<deleteData createDataKey="createSimpleProduct" stepKey="deleteProduct"/>
26+
</after>
27+
<!--Step 1 Add simple product to the cart -->
28+
<actionGroup ref="StorefrontAddSimpleProductToShoppingCartActionGroup" stepKey="addProductToCart">
29+
<argument name="product" value="$createSimpleProduct$"/>
30+
</actionGroup>
31+
32+
<!--Step 2 Proceed to Checkout and be on Shipping page -->
33+
<actionGroup ref="GoToCheckoutFromMinicartActionGroup" stepKey="goToCheckout"/>
34+
35+
<!--Step 3 Select Country as United Kingdom, select address street and Refresh the page-->
36+
<selectOption selector="{{CheckoutShippingSection.country}}" userInput="{{UK_Address.country_id}}" stepKey="selectUnitedKingdomCounty"/>
37+
<waitForPageLoad stepKey="waitFormToReloadAfterSelectCountry"/>
38+
<fillField selector="{{CheckoutShippingSection.street}}" userInput="{{UK_Address.street[0]}}" stepKey="enterAddressStreet"/>
39+
<actionGroup ref="ReloadPageActionGroup" stepKey="refreshPageAfterAddressIsAdded"/>
40+
<!-- Step 4 Assert Entered details should be retained and delete an address -->
41+
<seeInField selector="{{CheckoutShippingSection.street}}" userInput="{{UK_Address.street[0]}}" stepKey="seeAddressStreetUnitedKingdom"/>
42+
<clearField selector="{{CheckoutShippingSection.street}}" stepKey="deleteAddressStreet"/>
43+
<!-- Assert Entered details should be retained and State/Province field should be displayed as an optional field (without * ) -->
44+
<actionGroup ref="ReloadPageActionGroup" stepKey="refreshPageAfterAddressIsDeleted"/>
45+
<seeInField selector="{{CheckoutShippingSection.street}}" userInput="" stepKey="seeAddressStreetIsempty"/>
46+
</test>
47+
</tests>

app/code/Magento/Checkout/view/frontend/web/js/view/shipping.js

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,36 @@ define([
120120
$.extend(true, {}, checkoutProvider.get('shippingAddress'), shippingAddressData)
121121
);
122122
}
123-
checkoutProvider.on('shippingAddress', function (shippingAddrsData) {
124-
if (shippingAddrsData.street && !_.isEmpty(shippingAddrsData.street[0])) {
123+
checkoutProvider.on('shippingAddress', function (shippingAddrsData, changes) {
124+
var isStreetAddressDeleted, isStreetAddressNotEmpty;
125+
126+
/**
127+
* In last modifying operation street address was deleted.
128+
* @return {Boolean}
129+
*/
130+
isStreetAddressDeleted = function () {
131+
var change;
132+
133+
if (!changes || changes.length === 0) {
134+
return false;
135+
}
136+
137+
change = changes.pop();
138+
139+
if (_.isUndefined(change.value) || _.isUndefined(change.oldValue)) {
140+
return false;
141+
}
142+
143+
if (!change.path.startsWith('shippingAddress.street')) {
144+
return false;
145+
}
146+
147+
return change.value.length === 0 && change.oldValue.length > 0;
148+
};
149+
150+
isStreetAddressNotEmpty = shippingAddrsData.street && !_.isEmpty(shippingAddrsData.street[0]);
151+
152+
if (isStreetAddressNotEmpty || isStreetAddressDeleted()) {
125153
checkoutData.setShippingAddressFromData(shippingAddrsData);
126154
}
127155
});

app/code/Magento/ConfigurableProduct/Test/Unit/Ui/Component/Listing/AssociatedProduct/Columns/AttributesTest.php

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,13 @@ public function testPrepareDataSource()
109109
$name = 'some_name';
110110
$initialData = [
111111
'data' => [
112+
'totalRecords' => 4,
112113
'items' => [
113-
['attribute1_1_code' => 'attribute1_1_option2'],
114-
['attribute2_1_code' => 'attribute2_1_option3'],
115-
['attribute3_1_code' => 'attribute3_1_option3', 'attribute3_2_code' => 'attribute3_2_option1']
114+
['attribute1_1_code' => 'attribute1_1_option2', 'required_options' => '0'],
115+
['attribute2_1_code' => 'attribute2_1_option3', 'required_options' => '0'],
116+
['attribute3_1_code' => 'attribute3_1_option3', 'attribute3_2_code' => 'attribute3_2_option1',
117+
'required_options' => '0'],
118+
['attribute4_1_code' => 'attribute4_1_option1', 'required_options' => '1']
116119
]
117120
]
118121
];
@@ -158,18 +161,22 @@ public function testPrepareDataSource()
158161
];
159162
$resultData = [
160163
'data' => [
164+
'totalRecords' => 3,
161165
'items' => [
162166
[
163167
'attribute1_1_code' => 'attribute1_1_option2',
168+
'required_options' => '0',
164169
$name => 'attribute1_1_label: attribute1_1_option2_label'
165170
],
166171
[
167172
'attribute2_1_code' => 'attribute2_1_option3',
173+
'required_options' => '0',
168174
$name => ''
169175
],
170176
[
171177
'attribute3_1_code' => 'attribute3_1_option3',
172178
'attribute3_2_code' => 'attribute3_2_option1',
179+
'required_options' => '0',
173180
$name => 'attribute3_1_label: attribute3_1_option3_label,'
174181
. ' attribute3_2_label: attribute3_2_option1_label'
175182
]
@@ -187,7 +194,9 @@ public function testPrepareDataSource()
187194
->method('getItems')
188195
->willReturn($attributes);
189196

190-
$this->assertSame($resultData, $this->attributesColumn->prepareDataSource($initialData));
197+
$actualResultItems = $this->attributesColumn->prepareDataSource($initialData);
198+
$this->assertSame($resultData['data']['items'], $actualResultItems['data']['items']);
199+
$this->assertSame($resultData['data']['totalRecords'], count($actualResultItems['data']['items']));
191200
}
192201

193202
/**

app/code/Magento/ConfigurableProduct/Ui/Component/Listing/AssociatedProduct/Columns/Attributes.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,15 @@ public function prepareDataSource(array $dataSource)
5959
if (isset($dataSource['data']['items'])) {
6060
$attributes = $this->getAttributes();
6161
$fieldName = $this->getData('name');
62-
foreach ($dataSource['data']['items'] as & $item) {
62+
foreach ($dataSource['data']['items'] as $key => & $item) {
6363
$attrStrings = [];
6464
foreach ($attributes as $attributeCode => $attribute) {
65+
if ($item['required_options'] === "1") {
66+
unset($dataSource['data']['items'][$key]);
67+
$dataSource['data']['totalRecords']--;
68+
continue;
69+
}
70+
6571
if (isset($item[$attributeCode]) && isset($attribute['options'][$item[$attributeCode]])) {
6672
$attrStrings[] = $attribute['label'] . ': ' . $attribute['options'][$item[$attributeCode]];
6773
}
@@ -71,6 +77,7 @@ public function prepareDataSource(array $dataSource)
7177
}
7278
}
7379

80+
$dataSource['data']['items'] = array_values($dataSource['data']['items']);
7481
return $dataSource;
7582
}
7683

0 commit comments

Comments
 (0)