Skip to content

Commit edfa353

Browse files
author
Magento CICD
authored
merge magento/2.3-develop into magento-pangolin/RE-develop
2 parents 8ec681f + 39ff541 commit edfa353

File tree

53 files changed

+724
-59
lines changed

Some content is hidden

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

53 files changed

+724
-59
lines changed

app/code/Magento/Catalog/Controller/Adminhtml/Product/Attribute/Save.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,7 @@ public function execute()
139139
->setName($name)
140140
->getAttributeSet();
141141
} catch (AlreadyExistsException $alreadyExists) {
142-
$this->messageManager->addErrorMessage(
143-
__('A "%1" attribute set name already exists. Create a new name and try again.', $name)
144-
);
142+
$this->messageManager->addErrorMessage(__('An attribute set named \'%1\' already exists.', $name));
145143
$this->_session->setAttributeData($data);
146144
return $this->returnResult('catalog/*/edit', ['_current' => true], ['error' => true]);
147145
} catch (LocalizedException $e) {
@@ -202,6 +200,8 @@ public function execute()
202200
}
203201
}
204202

203+
$data = $this->presentation->convertPresentationDataToInputType($data);
204+
205205
if ($attributeId) {
206206
if (!$model->getId()) {
207207
$this->messageManager->addErrorMessage(__('This attribute no longer exists.'));
@@ -216,7 +216,7 @@ public function execute()
216216

217217
$data['attribute_code'] = $model->getAttributeCode();
218218
$data['is_user_defined'] = $model->getIsUserDefined();
219-
$data['frontend_input'] = $model->getFrontendInput();
219+
$data['frontend_input'] = $data['frontend_input'] ?? $model->getFrontendInput();
220220
} else {
221221
/**
222222
* @todo add to helper and specify all relations for properties
@@ -229,8 +229,6 @@ public function execute()
229229
);
230230
}
231231

232-
$data = $this->presentation->convertPresentationDataToInputType($data);
233-
234232
$data += ['is_filterable' => 0, 'is_filterable_in_search' => 0];
235233

236234
if ($model->getIsUserDefined() === null || $model->getIsUserDefined() != 0) {

app/code/Magento/Catalog/Model/Product/Attribute/Frontend/Inputtype/Presentation.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
* See COPYING.txt for license details.
55
*/
66

7+
declare(strict_types=1);
8+
79
namespace Magento\Catalog\Model\Product\Attribute\Frontend\Inputtype;
810

911
use Magento\Catalog\Model\ResourceModel\Eav\Attribute;
@@ -19,9 +21,9 @@ class Presentation
1921
* Get input type for presentation layer from stored input type.
2022
*
2123
* @param Attribute $attribute
22-
* @return string
24+
* @return string|null
2325
*/
24-
public function getPresentationInputType(Attribute $attribute)
26+
public function getPresentationInputType(Attribute $attribute) :?string
2527
{
2628
$inputType = $attribute->getFrontendInput();
2729
if ($inputType == 'textarea' && $attribute->getIsWysiwygEnabled()) {
@@ -37,12 +39,12 @@ public function getPresentationInputType(Attribute $attribute)
3739
*
3840
* @return array
3941
*/
40-
public function convertPresentationDataToInputType(array $data)
42+
public function convertPresentationDataToInputType(array $data) : array
4143
{
42-
if ($data['frontend_input'] === 'texteditor') {
44+
if (isset($data['frontend_input']) && $data['frontend_input'] === 'texteditor') {
4345
$data['is_wysiwyg_enabled'] = 1;
4446
$data['frontend_input'] = 'textarea';
45-
} elseif ($data['frontend_input'] === 'textarea') {
47+
} elseif (isset($data['frontend_input']) && $data['frontend_input'] === 'textarea') {
4648
$data['is_wysiwyg_enabled'] = 0;
4749
}
4850
return $data;
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
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\Test\Unit\Model\Product\Attribute\Frontend\InputType;
9+
10+
class PresentationTest extends \PHPUnit\Framework\TestCase
11+
{
12+
/**
13+
* @var \Magento\Catalog\Model\Product\Attribute\Frontend\Inputtype\Presentation
14+
*/
15+
private $presentation;
16+
17+
/**
18+
* @var \Magento\Catalog\Model\ResourceModel\Eav\Attribute| \PHPUnit_Framework_MockObject_MockObject
19+
*/
20+
private $attributeMock;
21+
22+
protected function setUp()
23+
{
24+
$this->presentation = new \Magento\Catalog\Model\Product\Attribute\Frontend\Inputtype\Presentation();
25+
$this->attributeMock = $this->getMockBuilder(\Magento\Catalog\Model\ResourceModel\Eav\Attribute::class)
26+
->disableOriginalConstructor()
27+
->getMock();
28+
}
29+
30+
/**
31+
* @param string $inputType
32+
* @param boolean $isWysiwygEnabled
33+
* @param string $expectedResult
34+
* @dataProvider getPresentationInputTypeDataProvider
35+
*/
36+
public function testGetPresentationInputType(string $inputType, bool $isWysiwygEnabled, string $expectedResult)
37+
{
38+
$this->attributeMock->expects($this->once())->method('getFrontendInput')->willReturn($inputType);
39+
$this->attributeMock->expects($this->any())->method('getIsWysiwygEnabled')->willReturn($isWysiwygEnabled);
40+
$this->assertEquals($expectedResult, $this->presentation->getPresentationInputType($this->attributeMock));
41+
}
42+
43+
public function getPresentationInputTypeDataProvider()
44+
{
45+
return [
46+
'attribute_is_textarea_and_wysiwyg_enabled' => ['textarea', true, 'texteditor'],
47+
'attribute_is_input_and_wysiwyg_enabled' => ['input', true, 'input'],
48+
'attribute_is_textarea_and_wysiwyg_disabled' => ['textarea', false, 'textarea'],
49+
];
50+
}
51+
52+
/**
53+
* @param array $data
54+
* @param array $expectedResult
55+
* @dataProvider convertPresentationDataToInputTypeDataProvider
56+
*/
57+
public function testConvertPresentationDataToInputType(array $data, array $expectedResult)
58+
{
59+
$this->assertEquals($expectedResult, $this->presentation->convertPresentationDataToInputType($data));
60+
}
61+
62+
public function convertPresentationDataToInputTypeDataProvider()
63+
{
64+
return [
65+
[['key' => 'value'], ['key' => 'value']],
66+
[
67+
['frontend_input' => 'texteditor'],
68+
['frontend_input' => 'textarea', 'is_wysiwyg_enabled' => 1]
69+
],
70+
[
71+
['frontend_input' => 'textarea'],
72+
['frontend_input' => 'textarea', 'is_wysiwyg_enabled' => 0]
73+
],
74+
[
75+
['frontend_input' => 'input'],
76+
['frontend_input' => 'input']
77+
]
78+
];
79+
}
80+
}

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,11 @@
6464
</parameter>
6565
<parameter name="cache_lifetime" xsi:type="text" visible="true">
6666
<label translate="true">Cache Lifetime (Seconds)</label>
67-
<description translate="true">86400 by default, if not set. To refresh instantly, clear the Blocks HTML Output cache.</description>
67+
<description translate="true">
68+
<![CDATA[Time in seconds between the widget updates.
69+
<br/>If not set, equals to 86400 seconds (24 hours). To update widget instantly, go to Cache Management and clear Blocks HTML Output cache.
70+
<br/>Widget will not show products that begin to match the specified conditions until cache is refreshed.]]>
71+
</description>
6872
</parameter>
6973
</parameters>
7074
<containers>

app/code/Magento/Catalog/i18n/en_US.csv

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -705,7 +705,13 @@ Template,Template
705705
"New Products Names Only Template","New Products Names Only Template"
706706
"New Products Images Only Template","New Products Images Only Template"
707707
"Cache Lifetime (Seconds)","Cache Lifetime (Seconds)"
708-
"86400 by default, if not set. To refresh instantly, clear the Blocks HTML Output cache.","86400 by default, if not set. To refresh instantly, clear the Blocks HTML Output cache."
708+
"Time in seconds between the widget updates.
709+
<br/>If not set, equals to 86400 seconds (24 hours). To update widget instantly, go to Cache Management and clear Blocks HTML Output cache.
710+
<br/>Widget will not show products that begin to match the specified conditions until cache is refreshed."
711+
,
712+
"Time in seconds between the widget updates.
713+
<br/>If not set, equals to 86400 seconds (24 hours). To update widget instantly, go to Cache Management and clear Blocks HTML Output cache.
714+
<br/>Widget will not show products that begin to match the specified conditions until cache is refreshed."
709715
"Catalog Product Link","Catalog Product Link"
710716
"Link to a Specified Product","Link to a Specified Product"
711717
"Select Product...","Select Product..."

app/code/Magento/CatalogWidget/etc/widget.xml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,11 @@
4040
</parameter>
4141
<parameter name="cache_lifetime" xsi:type="text" visible="true">
4242
<label translate="true">Cache Lifetime (Seconds)</label>
43-
<description translate="true">86400 by default, if not set. To refresh instantly, clear the Blocks HTML Output cache.</description>
43+
<description translate="true">
44+
<![CDATA[Time in seconds between the widget updates.
45+
<br/>If not set, equals to 86400 seconds (24 hours). To update widget instantly, go to Cache Management and clear Blocks HTML Output cache.
46+
<br/>Widget will not show products that begin to match the specified conditions until cache is refreshed.]]>
47+
</description>
4448
</parameter>
4549
<parameter name="condition" xsi:type="conditions" visible="true" required="true" sort_order="10"
4650
class="Magento\CatalogWidget\Block\Product\Widget\Conditions">

app/code/Magento/CatalogWidget/i18n/en_US.csv

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,11 @@ Title,Title
1616
Template,Template
1717
"Products Grid Template","Products Grid Template"
1818
"Cache Lifetime (Seconds)","Cache Lifetime (Seconds)"
19-
"86400 by default, if not set. To refresh instantly, clear the Blocks HTML Output cache.","86400 by default, if not set. To refresh instantly, clear the Blocks HTML Output cache."
19+
"Time in seconds between the widget updates.
20+
<br/>If not set, equals to 86400 seconds (24 hours). To update widget instantly, go to Cache Management and clear Blocks HTML Output cache.
21+
<br/>Widget will not show products that begin to match the specified conditions until cache is refreshed."
22+
,
23+
"Time in seconds between the widget updates.
24+
<br/>If not set, equals to 86400 seconds (24 hours). To update widget instantly, go to Cache Management and clear Blocks HTML Output cache.
25+
<br/>Widget will not show products that begin to match the specified conditions until cache is refreshed."
2026
Conditions,Conditions

app/code/Magento/Cms/Model/Wysiwyg/DefaultConfigProvider.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
* See COPYING.txt for license details.
55
*/
66

7+
declare(strict_types=1);
8+
79
namespace Magento\Cms\Model\Wysiwyg;
810

911
/**
@@ -27,7 +29,7 @@ public function __construct(\Magento\Framework\View\Asset\Repository $assetRepo)
2729
/**
2830
* {@inheritdoc}
2931
*/
30-
public function getConfig($config)
32+
public function getConfig(\Magento\Framework\DataObject $config) : \Magento\Framework\DataObject
3133
{
3234
$config->addData([
3335
'tinymce4' => [

app/code/Magento/Cms/Model/Wysiwyg/Gallery/DefaultConfigProvider.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
* See COPYING.txt for license details.
55
*/
66

7+
declare(strict_types=1);
8+
79
namespace Magento\Cms\Model\Wysiwyg\Gallery;
810

911
class DefaultConfigProvider implements \Magento\Framework\Data\Wysiwyg\ConfigProviderInterface
@@ -49,7 +51,7 @@ public function __construct(
4951
/**
5052
* {@inheritdoc}
5153
*/
52-
public function getConfig($config)
54+
public function getConfig(\Magento\Framework\DataObject $config) : \Magento\Framework\DataObject
5355
{
5456
$pluginData = (array) $config->getData('plugins');
5557
$imageData = [

app/code/Magento/Cms/Model/WysiwygDefaultConfig.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
7+
68
namespace Magento\Cms\Model;
79

810
class WysiwygDefaultConfig implements \Magento\Framework\Data\Wysiwyg\ConfigProviderInterface
911
{
1012
/**
1113
* {@inheritdoc}
1214
*/
13-
public function getConfig($config)
15+
public function getConfig(\Magento\Framework\DataObject $config) : \Magento\Framework\DataObject
1416
{
1517
return $config;
1618
}

0 commit comments

Comments
 (0)