Skip to content

Commit 2aa6e5a

Browse files
author
Sergey Semenov
committed
Merge remote-tracking branch 'mainline/develop' into MAGETWO-49820-Customer-validation
2 parents b634b2a + 135f967 commit 2aa6e5a

File tree

132 files changed

+4730
-1738
lines changed

Some content is hidden

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

132 files changed

+4730
-1738
lines changed

app/code/Magento/Backend/Block/System/Store/Edit/Form/Website.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ protected function _prepareStoreFieldset(\Magento\Framework\Data\Form $form)
9292
if ($this->_coreRegistry->registry('store_action') == 'edit') {
9393
$groups = $this->_groupFactory->create()->getCollection()->addWebsiteFilter(
9494
$websiteModel->getId()
95-
)->setWithoutStoreViewFilter()->toOptionArray();
95+
)->toOptionArray();
9696

9797
$fieldset->addField(
9898
'website_default_group_id',

app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/Gallery/Content.php

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -122,21 +122,40 @@ public function getAddImagesButton()
122122
*/
123123
public function getImagesJson()
124124
{
125-
if (is_array($this->getElement()->getImages())) {
126-
$value = $this->getElement()->getImages();
125+
$value = $this->getElement()->getImages();
126+
if (is_array($value) &&
127+
array_key_exists('images', $value) &&
128+
is_array($value['images']) &&
129+
count($value['images'])
130+
) {
127131
$directory = $this->_filesystem->getDirectoryRead(DirectoryList::MEDIA);
128-
if (is_array($value['images']) && count($value['images']) > 0) {
129-
foreach ($value['images'] as &$image) {
130-
$image['url'] = $this->_mediaConfig->getMediaUrl($image['file']);
131-
$fileHandler = $directory->stat($this->_mediaConfig->getMediaPath($image['file']));
132-
$image['size'] = $fileHandler['size'];
133-
}
134-
return $this->_jsonEncoder->encode($value['images']);
132+
$images = $this->sortImagesByPosition($value['images']);
133+
foreach ($images as &$image) {
134+
$image['url'] = $this->_mediaConfig->getMediaUrl($image['file']);
135+
$fileHandler = $directory->stat($this->_mediaConfig->getMediaPath($image['file']));
136+
$image['size'] = $fileHandler['size'];
135137
}
138+
return $this->_jsonEncoder->encode($images);
136139
}
137140
return '[]';
138141
}
139142

143+
/**
144+
* Sort images array by position key
145+
*
146+
* @param array $images
147+
* @return array
148+
*/
149+
private function sortImagesByPosition($images)
150+
{
151+
if (is_array($images)) {
152+
usort($images, function ($imageA, $imageB) {
153+
return ($imageA['position'] < $imageB['position']) ? -1 : 1;
154+
});
155+
}
156+
return $images;
157+
}
158+
140159
/**
141160
* @return string
142161
*/

app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Helper/Form/Gallery/ContentTest.php

Lines changed: 33 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -82,37 +82,59 @@ public function testGetImagesJson()
8282
['file_1.jpg', 'catalog/product/image_1.jpg'],
8383
['file_2.jpg', 'catalog/product/image_2.jpg']
8484
];
85-
// @codingStandardsIgnoreStart
86-
$encodedString = '[{"value_id":"1","file":"image_1.jpg","media_type":"image","url":"http:\/\/magento2.dev\/pub\/media\/catalog\/product\/image_1.jpg","size":879394},{"value_id":"2","file":"image_2.jpg","media_type":"image","url":"http:\/\/magento2.dev\/pub\/media\/catalog\/product\/image`_2.jpg","size":399659}]';
87-
// @codingStandardsIgnoreEnd
85+
86+
$sizeMap = [
87+
['catalog/product/image_1.jpg', ['size' => 399659]],
88+
['catalog/product/image_2.jpg', ['size' => 879394]]
89+
];
90+
91+
$imagesResult = [
92+
[
93+
'value_id' => '2',
94+
'file' => 'file_2.jpg',
95+
'media_type' => 'image',
96+
'position' => '0',
97+
'url' => 'url_to_the_image/image_2.jpg',
98+
'size' => 879394
99+
],
100+
[
101+
'value_id' => '1',
102+
'file' => 'file_1.jpg',
103+
'media_type' => 'image',
104+
'position' => '1',
105+
'url' => 'url_to_the_image/image_1.jpg',
106+
'size' => 399659
107+
]
108+
];
109+
88110
$images = [
89111
'images' => [
90112
[
91113
'value_id' => '1',
92114
'file' => 'file_1.jpg',
93115
'media_type' => 'image',
116+
'position' => '1'
94117
] ,
95118
[
96119
'value_id' => '2',
97120
'file' => 'file_2.jpg',
98121
'media_type' => 'image',
122+
'position' => '0'
99123
]
100124
]
101125
];
102-
$firstStat = ['size' => 879394];
103-
$secondStat = ['size' => 399659];
126+
104127
$this->content->setElement($this->galleryMock);
105-
$this->galleryMock->expects($this->any())->method('getImages')->willReturn($images);
128+
$this->galleryMock->expects($this->once())->method('getImages')->willReturn($images);
106129
$this->fileSystemMock->expects($this->once())->method('getDirectoryRead')->willReturn($this->readMock);
107130

108131
$this->mediaConfigMock->expects($this->any())->method('getMediaUrl')->willReturnMap($url);
109-
$this->mediaConfigMock->expects($this->any())->method('getMediaPath')->willReturn($mediaPath);
132+
$this->mediaConfigMock->expects($this->any())->method('getMediaPath')->willReturnMap($mediaPath);
110133

111-
$this->readMock->expects($this->at(0))->method('stat')->willReturn($firstStat);
112-
$this->readMock->expects($this->at(1))->method('stat')->willReturn($secondStat);
113-
$this->jsonEncoderMock->expects($this->once())->method('encode')->willReturn($encodedString);
134+
$this->readMock->expects($this->any())->method('stat')->willReturnMap($sizeMap);
135+
$this->jsonEncoderMock->expects($this->once())->method('encode')->willReturnCallback('json_encode');
114136

115-
$this->assertSame($encodedString, $this->content->getImagesJson());
137+
$this->assertSame(json_encode($imagesResult), $this->content->getImagesJson());
116138
}
117139

118140
public function testGetImagesJsonWithoutImages()

app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Categories.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ protected function createNewCategoryModal(array $meta)
104104
'config' => [
105105
'isTemplate' => false,
106106
'componentType' => 'modal',
107-
'dataScope' => 'data.new_category',
108107
'options' => [
109108
'title' => __('New Category'),
110109
],
@@ -193,7 +192,6 @@ protected function customizeCategoriesField(array $meta)
193192
'levelsVisibility' => '1',
194193
'elementTmpl' => 'ui/grid/filters/elements/ui-select',
195194
'options' => $this->getCategoriesTree(),
196-
'scopeLabel' => null,
197195
'listens' => [
198196
'index=create_category:responseData' => 'setParsed',
199197
'newOption' => 'toggleOptionSelected'

app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/General.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,14 +259,12 @@ protected function customizeNewDateRangeField(array $meta)
259259
if ($fromFieldPath && $toFieldPath) {
260260
$fromContainerPath = $this->arrayManager->slicePath($fromFieldPath, 0, -2);
261261
$toContainerPath = $this->arrayManager->slicePath($toFieldPath, 0, -2);
262-
$scopeLabel = $this->arrayManager->get($fromFieldPath . self::META_CONFIG_PATH . '/scopeLabel', $meta);
263262

264263
$meta = $this->arrayManager->merge(
265264
$fromFieldPath . self::META_CONFIG_PATH,
266265
$meta,
267266
[
268267
'label' => __('Set Product as New From'),
269-
'scopeLabel' => null,
270268
'additionalClasses' => 'admin__field-date',
271269
]
272270
);
@@ -287,7 +285,6 @@ protected function customizeNewDateRangeField(array $meta)
287285
'additionalClasses' => 'admin__control-grouped-date',
288286
'breakLine' => false,
289287
'component' => 'Magento_Ui/js/form/components/group',
290-
'scopeLabel' => $scopeLabel,
291288
]
292289
);
293290
$meta = $this->arrayManager->set(

app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/ScheduleDesignUpdate.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,12 @@ protected function customizeDateRangeField(array $meta)
6868
$toFieldPath = $this->arrayManager->findPath(self::CODE_CUSTOM_DESIGN_TO, $meta, null, 'children');
6969
$fromContainerPath = $this->arrayManager->slicePath($fromFieldPath, 0, -2);
7070
$toContainerPath = $this->arrayManager->slicePath($toFieldPath, 0, -2);
71-
$scopeLabel = $this->arrayManager->get($fromFieldPath . self::META_CONFIG_PATH . '/scopeLabel', $meta);
7271

7372
$meta = $this->arrayManager->merge(
7473
$fromFieldPath . self::META_CONFIG_PATH,
7574
$meta,
7675
[
7776
'label' => __('Schedule Update From'),
78-
'scopeLabel' => null,
7977
'additionalClasses' => 'admin__field-date',
8078
]
8179
);
@@ -96,7 +94,6 @@ protected function customizeDateRangeField(array $meta)
9694
'additionalClasses' => 'admin__control-grouped-date',
9795
'breakLine' => false,
9896
'component' => 'Magento_Ui/js/form/components/group',
99-
'scopeLabel' => $scopeLabel,
10097
]
10198
);
10299
$meta = $this->arrayManager->set(

app/code/Magento/Catalog/view/adminhtml/ui_component/category_form.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -552,11 +552,11 @@
552552
<field name="custom_design_from">
553553
<argument name="data" xsi:type="array">
554554
<item name="config" xsi:type="array">
555+
<item name="label" xsi:type="string" translate="true">Schedule Update From</item>
555556
<item name="additionalClasses" xsi:type="string">admin__field-date</item>
556557
<item name="sortOrder" xsi:type="number">230</item>
557558
<item name="dataType" xsi:type="string">string</item>
558559
<item name="formElement" xsi:type="string">date</item>
559-
<item name="scopeLabel" xsi:type="string"/>
560560
<item name="imports" xsi:type="array">
561561
<item name="disabled" xsi:type="string">ns = ${ $.ns }, index = custom_use_parent_settings :checked</item>
562562
</item>

app/code/Magento/Catalog/view/frontend/web/js/catalog-add-to-cart.js

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,9 @@ define([
2020
productStatusSelector: '.stock.available',
2121
addToCartButtonSelector: '.action.tocart',
2222
addToCartButtonDisabledClass: 'disabled',
23-
addToCartButtonTextWhileAdding: $t('Adding...'),
24-
addToCartButtonTextAdded: $t('Added'),
25-
addToCartButtonTextDefault: $t('Add to Cart')
26-
23+
addToCartButtonTextWhileAdding: '',
24+
addToCartButtonTextAdded: '',
25+
addToCartButtonTextDefault: ''
2726
},
2827

2928
_create: function() {
@@ -108,26 +107,29 @@ define([
108107
},
109108

110109
disableAddToCartButton: function(form) {
110+
var addToCartButtonTextWhileAdding = this.options.addToCartButtonTextWhileAdding || $t('Adding...');
111111
var addToCartButton = $(form).find(this.options.addToCartButtonSelector);
112112
addToCartButton.addClass(this.options.addToCartButtonDisabledClass);
113-
addToCartButton.attr('title', this.options.addToCartButtonTextWhileAdding);
114-
addToCartButton.find('span').text(this.options.addToCartButtonTextWhileAdding);
113+
addToCartButton.find('span').text(addToCartButtonTextWhileAdding);
114+
addToCartButton.attr('title', addToCartButtonTextWhileAdding);
115115
},
116116

117117
enableAddToCartButton: function(form) {
118+
var addToCartButtonTextAdded = this.options.addToCartButtonTextAdded || $t('Added');
118119
var self = this,
119120
addToCartButton = $(form).find(this.options.addToCartButtonSelector);
120121

121-
addToCartButton.find('span').text(this.options.addToCartButtonTextAdded);
122-
addToCartButton.attr('title', this.options.addToCartButtonTextAdded);
122+
addToCartButton.find('span').text(addToCartButtonTextAdded);
123+
addToCartButton.attr('title', addToCartButtonTextAdded);
123124

124125
setTimeout(function() {
126+
var addToCartButtonTextDefault = self.options.addToCartButtonTextDefault || $t('Add to Cart');
125127
addToCartButton.removeClass(self.options.addToCartButtonDisabledClass);
126-
addToCartButton.find('span').text(self.options.addToCartButtonTextDefault);
127-
addToCartButton.attr('title', self.options.addToCartButtonTextDefault);
128+
addToCartButton.find('span').text(addToCartButtonTextDefault);
129+
addToCartButton.attr('title', addToCartButtonTextDefault);
128130
}, 1000);
129131
}
130132
});
131133

132134
return $.mage.catalogAddToCart;
133-
});
135+
});

app/code/Magento/CatalogImportExport/Model/Import/Product.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1270,7 +1270,7 @@ protected function _saveProductCategories(array $categoriesData)
12701270
);
12711271
}
12721272
if ($categoriesIn) {
1273-
$this->_connection->insertOnDuplicate($tableName, $categoriesIn, ['position']);
1273+
$this->_connection->insertOnDuplicate($tableName, $categoriesIn, ['product_id', 'category_id']);
12741274
}
12751275
}
12761276
return $this;

app/code/Magento/CatalogInventory/Ui/DataProvider/Product/Form/Modifier/AdvancedInventory.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,8 @@ private function prepareMeta()
176176
'visible' => '1',
177177
'require' => '0',
178178
'additionalClasses' => 'admin__field-small',
179+
'label' => __('Quantity'),
180+
'scopeLabel' => '[GLOBAL]',
179181
'dataScope' => 'qty',
180182
'validation' => [
181183
'validate-number' => true,

0 commit comments

Comments
 (0)