Skip to content

Commit fe0c96e

Browse files
committed
MAGETWO-56557: GITHUB PR#2791
2 parents 3551a3d + 3ef1e28 commit fe0c96e

File tree

90 files changed

+2074
-492
lines changed

Some content is hidden

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

90 files changed

+2074
-492
lines changed

app/code/Magento/Backend/view/adminhtml/ui_component/design_config_form.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@
6969
<item name="fit" xsi:type="boolean">false</item>
7070
<item name="label" xsi:type="string">Search String</item>
7171
<item name="showFallbackReset" xsi:type="boolean">false</item>
72+
<item name="validation" xsi:type="array">
73+
<item name="required-entry" xsi:type="boolean">true</item>
74+
</item>
7275
</item>
7376
</argument>
7477
</field>
@@ -82,6 +85,9 @@
8285
<item name="fit" xsi:type="boolean">false</item>
8386
<item name="label" xsi:type="string">Theme Name</item>
8487
<item name="showFallbackReset" xsi:type="boolean">false</item>
88+
<item name="validation" xsi:type="array">
89+
<item name="required-entry" xsi:type="boolean">true</item>
90+
</item>
8591
</item>
8692
</argument>
8793
</field>

app/code/Magento/Backend/view/adminhtml/web/template/dynamic-rows/cells/action-delete.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@
1111
title: $parent.deleteButtonLabel
1212
}
1313
">
14-
<span data-bind="text: $parent.deleteButtonLabel"></span>
14+
<span translate="$parent.deleteButtonLabel"></span>
1515
</button>

app/code/Magento/Backend/view/adminhtml/web/template/dynamic-rows/grid.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
class="action-secondary"
1717
type="button"
1818
click="processingAddChild.bind($data, false, false, false)">
19-
<span text="addButtonLabel"/>
19+
<span translate="addButtonLabel"/>
2020
</button>
2121
</div>
2222

@@ -30,7 +30,7 @@
3030
css="element.setClasses(element)"
3131
attr="'data-index': index">
3232
<label if="element.label" class="admin__field-label" attr="for: element.uid">
33-
<span text="element.label"/>
33+
<span translate="element.label"/>
3434
</label>
3535

3636
<div class="admin__field-control" data-role="grid-wrapper">
@@ -51,7 +51,7 @@
5151

5252
<th repeat="foreach: labels, item: '$label'"
5353
class="data-grid-th"
54-
text="$label().label"
54+
translate="$label().label"
5555
visible="$label().visible"
5656
disable="$label().disabled"
5757
css="setClasses($label())">

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ public function execute()
132132
$attributesData[$attributeCode] = $value;
133133
} elseif ($attribute->getFrontendInput() == 'multiselect') {
134134
// Check if 'Change' checkbox has been checked by admin for this attribute
135-
$isChanged = (bool)$this->getRequest()->getPost($attributeCode . '_checkbox');
135+
$isChanged = (bool)$this->getRequest()->getPost('toggle_' . $attributeCode);
136136
if (!$isChanged) {
137137
unset($attributesData[$attributeCode]);
138138
continue;

app/code/Magento/Catalog/Model/Product.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1468,7 +1468,10 @@ public function getMediaGalleryImages()
14681468
if (!$this->hasData('media_gallery_images') && is_array($this->getMediaGallery('images'))) {
14691469
$images = $this->_collectionFactory->create();
14701470
foreach ($this->getMediaGallery('images') as $image) {
1471-
if ((isset($image['disabled']) && $image['disabled']) || empty($image['value_id'])) {
1471+
if ((isset($image['disabled']) && $image['disabled'])
1472+
|| empty($image['value_id'])
1473+
|| $images->getItemById($image['value_id']) != null
1474+
) {
14721475
continue;
14731476
}
14741477
$image['url'] = $this->getMediaConfig()->getMediaUrl($image['file']);

app/code/Magento/Catalog/Test/Unit/Model/ProductTest.php

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,16 @@ class ProductTest extends \PHPUnit_Framework_TestCase
185185
*/
186186
private $extensionAttributesFactory;
187187

188+
/**
189+
* @var \Magento\Framework\Filesystem
190+
*/
191+
private $filesystemMock;
192+
193+
/**
194+
* @var \Magento\Framework\Data\CollectionFactory
195+
*/
196+
private $collectionFactoryMock;
197+
188198
/**
189199
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
190200
*/
@@ -374,6 +384,13 @@ protected function setUp()
374384
$this->extensionAttributesFactory = $this->getMockBuilder(ExtensionAttributesFactory::class)
375385
->disableOriginalConstructor()
376386
->getMock();
387+
$this->filesystemMock = $this->getMockBuilder(\Magento\Framework\Filesystem::class)
388+
->disableOriginalConstructor()
389+
->getMock();
390+
$this->collectionFactoryMock = $this->getMockBuilder(\Magento\Framework\Data\CollectionFactory::class)
391+
->disableOriginalConstructor()
392+
->setMethods(['create'])
393+
->getMock();
377394
$this->mediaConfig = $this->getMock(\Magento\Catalog\Model\Product\Media\Config::class, [], [], '', false);
378395
$this->objectManagerHelper = new ObjectManagerHelper($this);
379396

@@ -402,6 +419,8 @@ protected function setUp()
402419
'mediaGalleryEntryConverterPool' => $this->mediaGalleryEntryConverterPoolMock,
403420
'linkRepository' => $this->productLinkRepositoryMock,
404421
'catalogProductMediaConfig' => $this->mediaConfig,
422+
'_filesystem' => $this->filesystemMock,
423+
'_collectionFactory' => $this->collectionFactoryMock,
405424
'data' => ['id' => 1]
406425
]
407426
);
@@ -1230,6 +1249,71 @@ public function testSetMediaGalleryEntries()
12301249
$this->assertEquals($expectedResult, $this->model->getMediaGallery());
12311250
}
12321251

1252+
public function testGetMediaGalleryImagesMerging()
1253+
{
1254+
$mediaEntries = [
1255+
'images' => [
1256+
[
1257+
'value_id' => 1,
1258+
'file' => 'imageFile.jpg',
1259+
'media_type' => 'image',
1260+
],
1261+
[
1262+
'value_id' => 1,
1263+
'file' => 'imageFile.jpg',
1264+
],
1265+
[
1266+
'value_id' => 2,
1267+
'file' => 'smallImageFile.jpg',
1268+
'media_type' => 'image',
1269+
],
1270+
]
1271+
];
1272+
$expectedImageDataObject = new \Magento\Framework\DataObject([
1273+
'value_id' => 1,
1274+
'file' => 'imageFile.jpg',
1275+
'media_type' => 'image',
1276+
'url' => 'http://magento.dev/pub/imageFile.jpg',
1277+
'id' => 1,
1278+
'path' => '/var/www/html/pub/imageFile.jpg',
1279+
]);
1280+
$expectedSmallImageDataObject = new \Magento\Framework\DataObject([
1281+
'value_id' => 2,
1282+
'file' => 'smallImageFile.jpg',
1283+
'media_type' => 'image',
1284+
'url' => 'http://magento.dev/pub/smallImageFile.jpg',
1285+
'id' => 2,
1286+
'path' => '/var/www/html/pub/smallImageFile.jpg',
1287+
]);
1288+
1289+
$directoryMock = $this->getMockBuilder(\Magento\Framework\Filesystem\Directory\ReadInterface::class)
1290+
->disableOriginalConstructor()
1291+
->getMock();
1292+
$this->filesystemMock->expects($this->once())->method('getDirectoryRead')->willReturn($directoryMock);
1293+
$this->model->setData('media_gallery', $mediaEntries);
1294+
$imagesCollectionMock = $this->getMockBuilder(\Magento\Framework\Data\Collection::class)
1295+
->disableOriginalConstructor()
1296+
->getMock();
1297+
$this->collectionFactoryMock->expects($this->once())->method('create')->willReturn($imagesCollectionMock);
1298+
$imagesCollectionMock->expects($this->at(2))->method('getItemById')->with(1)->willReturn($expectedImageDataObject);
1299+
$this->mediaConfig->expects($this->at(0))
1300+
->method('getMediaUrl')
1301+
->willReturn('http://magento.dev/pub/imageFile.jpg');
1302+
$directoryMock->expects($this->at(0))
1303+
->method('getAbsolutePath')
1304+
->willReturn('/var/www/html/pub/imageFile.jpg');
1305+
$this->mediaConfig->expects($this->at(2))
1306+
->method('getMediaUrl')
1307+
->willReturn('http://magento.dev/pub/smallImageFile.jpg');
1308+
$directoryMock->expects($this->at(1))
1309+
->method('getAbsolutePath')
1310+
->willReturn('/var/www/html/pub/smallImageFile.jpg');
1311+
$imagesCollectionMock->expects($this->at(1))->method('addItem')->with($expectedImageDataObject);
1312+
$imagesCollectionMock->expects($this->at(4))->method('addItem')->with($expectedSmallImageDataObject);
1313+
1314+
$this->model->getMediaGalleryImages();
1315+
}
1316+
12331317
public function testGetCustomAttributes()
12341318
{
12351319
$priceCode = 'price';

0 commit comments

Comments
 (0)