Skip to content

Commit 5c70f7d

Browse files
author
Roman Lytvynenko
committed
Merge branch '2.4-develop' of https://github.com/magento/magento2ce into MC-29167
2 parents b929cc7 + c644992 commit 5c70f7d

File tree

287 files changed

+10912
-3752
lines changed

Some content is hidden

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

287 files changed

+10912
-3752
lines changed

app/code/Magento/AdvancedSearch/etc/adminhtml/system.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
<field id="search_suggestion_enabled">1</field>
6161
</depends>
6262
</field>
63-
<field id="search_suggestion_count_results_enabled" translate="label" type="select" sortOrder="92" showInDefault="1" showInWebsite="1" showInStore="1">
63+
<field id="search_suggestion_count_results_enabled" translate="label comment" type="select" sortOrder="92" showInDefault="1" showInWebsite="1" showInStore="1">
6464
<label>Show Results Count for Each Suggestion</label>
6565
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
6666
<comment>When you enable this option your site may slow down.</comment>

app/code/Magento/Analytics/etc/adminhtml/system.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
<frontend_model>Magento\Analytics\Block\Adminhtml\System\Config\CollectionTimeLabel</frontend_model>
3030
<backend_model>Magento\Analytics\Model\Config\Backend\CollectionTime</backend_model>
3131
</field>
32-
<field id="vertical" translate="label comment" type="select" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="0">
32+
<field id="vertical" translate="hint label comment" type="select" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="0">
3333
<hint>Industry Data</hint>
3434
<label>Industry</label>
3535
<comment>In order to personalize your Advanced Reporting experience, please select your industry.</comment>

app/code/Magento/AsynchronousOperations/view/adminhtml/ui_component/bulk_listing.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@
9292
<actionsColumn name="actions" class="\Magento\AsynchronousOperations\Ui\Component\Listing\Column\Actions">
9393
<settings>
9494
<indexField>id</indexField>
95-
<label>Action</label>
95+
<label translate="true">Action</label>
9696
</settings>
9797
</actionsColumn>
9898
</columns>

app/code/Magento/Backend/Block/System/Account/Edit/Form.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public function __construct(
6868
}
6969

7070
/**
71-
* {@inheritdoc}
71+
* @inheritdoc
7272
*/
7373
protected function _prepareForm()
7474
{
@@ -114,7 +114,7 @@ protected function _prepareForm()
114114
'name' => 'password',
115115
'label' => __('New Password'),
116116
'title' => __('New Password'),
117-
'class' => 'validate-admin-password admin__control-text'
117+
'class' => 'validate-admin-password'
118118
]
119119
);
120120

@@ -124,7 +124,7 @@ protected function _prepareForm()
124124
[
125125
'name' => 'password_confirmation',
126126
'label' => __('Password Confirmation'),
127-
'class' => 'validate-cpassword admin__control-text'
127+
'class' => 'validate-cpassword'
128128
]
129129
);
130130

@@ -152,7 +152,7 @@ protected function _prepareForm()
152152
'label' => __('Your Password'),
153153
'id' => self::IDENTITY_VERIFICATION_PASSWORD_FIELD,
154154
'title' => __('Your Password'),
155-
'class' => 'validate-current-password required-entry admin__control-text',
155+
'class' => 'validate-current-password required-entry',
156156
'required' => true
157157
]
158158
);
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
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\Backend\Test\Unit\Helper;
9+
10+
use Magento\Backend\Helper\Js;
11+
use PHPUnit\Framework\TestCase;
12+
13+
/**
14+
* Class JsTest
15+
*
16+
* Testing decoding serialized grid data
17+
*/
18+
class JsTest extends TestCase
19+
{
20+
/**
21+
* @var Js
22+
*/
23+
private $helper;
24+
25+
/**
26+
* Set Up
27+
*/
28+
protected function setUp()
29+
{
30+
$this->helper = new Js();
31+
}
32+
33+
/**
34+
* Test decoding the serialized input
35+
*
36+
* @dataProvider getEncodedDataProvider
37+
*
38+
* @param string $encoded
39+
* @param array $expected
40+
*/
41+
public function testDecodeGridSerializedInput(string $encoded, array $expected)
42+
{
43+
$this->assertEquals($expected, $this->helper->decodeGridSerializedInput($encoded));
44+
}
45+
46+
/**
47+
* Get serialized grid input
48+
*
49+
* @return array
50+
*/
51+
public function getEncodedDataProvider(): array
52+
{
53+
return [
54+
'Decoding empty serialized string' => [
55+
'',
56+
[]
57+
],
58+
'Decoding a simplified serialized string' => [
59+
'1&2&3&4',
60+
[1, 2, 3, 4]
61+
],
62+
'Decoding encoded serialized string' => [
63+
'2=dGVzdC1zdHJpbmc=',
64+
[
65+
2 => [
66+
'test-string' => ''
67+
]
68+
]
69+
],
70+
'Decoding multiple encoded serialized strings' => [
71+
'2=dGVzdC1zdHJpbmc=&3=bmV3LXN0cmluZw==',
72+
[
73+
2 => [
74+
'test-string' => ''
75+
],
76+
3 => [
77+
'new-string' => ''
78+
]
79+
]
80+
]
81+
];
82+
}
83+
}

app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Edit/Tab/Advanced.php

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,20 @@
77
namespace Magento\Catalog\Block\Adminhtml\Product\Attribute\Edit\Tab;
88

99
use Magento\Backend\Block\Widget\Form\Generic;
10+
use Magento\Catalog\Model\ResourceModel\Eav\Attribute;
1011
use Magento\Config\Model\Config\Source\Yesno;
1112
use Magento\Eav\Block\Adminhtml\Attribute\PropertyLocker;
1213
use Magento\Eav\Helper\Data;
1314
use Magento\Framework\App\ObjectManager;
15+
use Magento\Framework\Exception\LocalizedException;
16+
use Magento\Framework\Stdlib\DateTime;
1417

1518
/**
16-
* Product attribute add/edit form main tab
19+
* Product attribute add/edit advanced form tab
1720
*
1821
* @api
1922
* @since 100.0.2
23+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
2024
*/
2125
class Advanced extends Generic
2226
{
@@ -70,7 +74,7 @@ public function __construct(
7074
* Adding product form elements for editing attribute
7175
*
7276
* @return $this
73-
* @throws \Magento\Framework\Exception\LocalizedException
77+
* @throws LocalizedException
7478
* @SuppressWarnings(PHPMD)
7579
*/
7680
protected function _prepareForm()
@@ -139,7 +143,21 @@ protected function _prepareForm()
139143
'label' => __('Default Value'),
140144
'title' => __('Default Value'),
141145
'value' => $attributeObject->getDefaultValue(),
142-
'date_format' => $dateFormat
146+
'date_format' => $dateFormat,
147+
]
148+
);
149+
150+
$timeFormat = $this->_localeDate->getTimeFormat(\IntlDateFormatter::SHORT);
151+
$fieldset->addField(
152+
'default_value_datetime',
153+
'date',
154+
[
155+
'name' => 'default_value_datetime',
156+
'label' => __('Default Value'),
157+
'title' => __('Default Value'),
158+
'value' => $this->getLocalizedDateDefaultValue(),
159+
'date_format' => $dateFormat,
160+
'time_format' => $timeFormat,
143161
]
144162
);
145163

@@ -266,7 +284,7 @@ protected function _initFormValues()
266284
/**
267285
* Retrieve attribute object from registry
268286
*
269-
* @return mixed
287+
* @return Attribute
270288
*/
271289
private function getAttributeObject()
272290
{
@@ -285,4 +303,28 @@ private function getPropertyLocker()
285303
}
286304
return $this->propertyLocker;
287305
}
306+
307+
/**
308+
* Get localized date default value
309+
*
310+
* @return string
311+
* @throws LocalizedException
312+
*/
313+
private function getLocalizedDateDefaultValue(): string
314+
{
315+
$attributeObject = $this->getAttributeObject();
316+
if (empty($attributeObject->getDefaultValue()) || $attributeObject->getFrontendInput() !== 'datetime') {
317+
return (string)$attributeObject->getDefaultValue();
318+
}
319+
320+
try {
321+
$localizedDate = $this->_localeDate->date($attributeObject->getDefaultValue(), null, false);
322+
$localizedDate->setTimezone(new \DateTimeZone($this->_localeDate->getConfigTimezone()));
323+
$localizedDate = $localizedDate->format(DateTime::DATETIME_PHP_FORMAT);
324+
} catch (\Exception $e) {
325+
throw new LocalizedException(__('The default date is invalid.'));
326+
}
327+
328+
return $localizedDate;
329+
}
288330
}

app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Edit/Tab/Main.php

Lines changed: 72 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -7,60 +7,60 @@
77
/**
88
* Product attribute add/edit form main tab
99
*
10-
* @author Magento Core Team <[email protected]>
10+
* @author Magento Core Team <[email protected]>
1111
*/
1212
namespace Magento\Catalog\Block\Adminhtml\Product\Attribute\Edit\Tab;
1313

14+
use Magento\Catalog\Block\Adminhtml\Product\Helper\Form\Apply as HelperApply;
1415
use Magento\Eav\Block\Adminhtml\Attribute\Edit\Main\AbstractMain;
16+
use Magento\Framework\Data\Form\Element\AbstractElement;
17+
use Magento\Framework\Data\Form\Element\Fieldset;
18+
use Magento\Framework\DataObject;
1519

1620
/**
21+
* Product attribute add/edit form main tab
22+
*
1723
* @api
18-
* @SuppressWarnings(PHPMD.DepthOfInheritance)
1924
* @since 100.0.2
2025
*/
2126
class Main extends AbstractMain
2227
{
2328
/**
24-
* Adding product form elements for editing attribute
25-
*
26-
* @return $this
27-
* @SuppressWarnings(PHPMD.UnusedLocalVariable)
29+
* @inheritdoc
2830
*/
2931
protected function _prepareForm()
3032
{
3133
parent::_prepareForm();
32-
/** @var \Magento\Catalog\Model\ResourceModel\Eav\Attribute $attributeObject */
33-
$attributeObject = $this->getAttributeObject();
34-
/* @var $form \Magento\Framework\Data\Form */
35-
$form = $this->getForm();
36-
/* @var $fieldset \Magento\Framework\Data\Form\Element\Fieldset */
37-
$fieldset = $form->getElement('base_fieldset');
38-
$fieldsToRemove = ['attribute_code', 'is_unique', 'frontend_class'];
3934

40-
foreach ($fieldset->getElements() as $element) {
41-
/** @var \Magento\Framework\Data\Form\AbstractForm $element */
42-
if (substr($element->getId(), 0, strlen('default_value')) == 'default_value') {
43-
$fieldsToRemove[] = $element->getId();
44-
}
45-
}
46-
foreach ($fieldsToRemove as $id) {
47-
$fieldset->removeField($id);
48-
}
35+
$this->removeUnusedFields();
36+
$this->processFrontendInputTypes();
37+
38+
$this->_eventManager->dispatch('product_attribute_form_build_main_tab', ['form' => $this->getForm()]);
39+
40+
return $this;
41+
}
4942

43+
/**
44+
* @inheritdoc
45+
*/
46+
protected function _getAdditionalElementTypes()
47+
{
48+
return ['apply' => HelperApply::class];
49+
}
50+
51+
/**
52+
* Process frontend input types for product attributes
53+
*
54+
* @return void
55+
*/
56+
private function processFrontendInputTypes(): void
57+
{
58+
$form = $this->getForm();
59+
/** @var AbstractElement $frontendInputElm */
5060
$frontendInputElm = $form->getElement('frontend_input');
51-
$additionalTypes = [
52-
['value' => 'price', 'label' => __('Price')],
53-
['value' => 'media_image', 'label' => __('Media Image')],
54-
];
55-
$additionalReadOnlyTypes = ['gallery' => __('Gallery')];
56-
if (isset($additionalReadOnlyTypes[$attributeObject->getFrontendInput()])) {
57-
$additionalTypes[] = [
58-
'value' => $attributeObject->getFrontendInput(),
59-
'label' => $additionalReadOnlyTypes[$attributeObject->getFrontendInput()],
60-
];
61-
}
61+
$additionalTypes = $this->getAdditionalFrontendInputTypes();
6262

63-
$response = new \Magento\Framework\DataObject();
63+
$response = new DataObject();
6464
$response->setTypes([]);
6565
$this->_eventManager->dispatch('adminhtml_product_attribute_types', ['response' => $response]);
6666
$_hiddenFields = [];
@@ -74,19 +74,51 @@ protected function _prepareForm()
7474

7575
$frontendInputValues = array_merge($frontendInputElm->getValues(), $additionalTypes);
7676
$frontendInputElm->setValues($frontendInputValues);
77+
}
7778

78-
$this->_eventManager->dispatch('product_attribute_form_build_main_tab', ['form' => $form]);
79+
/**
80+
* Get additional Frontend Input Types for product attributes
81+
*
82+
* @return array
83+
*/
84+
private function getAdditionalFrontendInputTypes(): array
85+
{
86+
$additionalTypes = [
87+
['value' => 'price', 'label' => __('Price')],
88+
['value' => 'media_image', 'label' => __('Media Image')],
89+
];
7990

80-
return $this;
91+
$additionalReadOnlyTypes = ['gallery' => __('Gallery')];
92+
$attributeObject = $this->getAttributeObject();
93+
if (isset($additionalReadOnlyTypes[$attributeObject->getFrontendInput()])) {
94+
$additionalTypes[] = [
95+
'value' => $attributeObject->getFrontendInput(),
96+
'label' => $additionalReadOnlyTypes[$attributeObject->getFrontendInput()],
97+
];
98+
}
99+
100+
return $additionalTypes;
81101
}
82102

83103
/**
84-
* Retrieve additional element types for product attributes
104+
* Remove unused form fields
85105
*
86-
* @return array
106+
* @return void
87107
*/
88-
protected function _getAdditionalElementTypes()
108+
private function removeUnusedFields(): void
89109
{
90-
return ['apply' => \Magento\Catalog\Block\Adminhtml\Product\Helper\Form\Apply::class];
110+
$form = $this->getForm();
111+
/* @var $fieldset Fieldset */
112+
$fieldset = $form->getElement('base_fieldset');
113+
$fieldsToRemove = ['attribute_code', 'is_unique', 'frontend_class'];
114+
foreach ($fieldset->getElements() as $element) {
115+
/** @var AbstractElement $element */
116+
if (substr($element->getId(), 0, strlen('default_value')) === 'default_value') {
117+
$fieldsToRemove[] = $element->getId();
118+
}
119+
}
120+
foreach ($fieldsToRemove as $id) {
121+
$fieldset->removeField($id);
122+
}
91123
}
92124
}

0 commit comments

Comments
 (0)