Skip to content

Commit d01521a

Browse files
author
Joan He
committed
Merge remote-tracking branch 'upstream/develop' into pr
2 parents ad67779 + b5b3bbf commit d01521a

File tree

33 files changed

+721
-202
lines changed

33 files changed

+721
-202
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
</label>
3535

3636
<div class="admin__field-control" data-role="grid-wrapper">
37-
<div class="admin__control-table-pagination" visible="!!$data.recordData().length">
37+
<div class="admin__control-table-pagination" visible="!!element.getRecordCount()">
3838
<div class="admin__data-grid-pager">
3939
<button class="action-previous" type="button" data-bind="attr: {title: $t('Previous Page')}, click: previousPage, disable: isFirst()"></button>
4040
<input class="admin__control-text" type="number" data-bind="attr: {id: ++ko.uid}, value: currentPage">
@@ -51,10 +51,10 @@
5151

5252
<th repeat="foreach: labels, item: '$label'"
5353
class="data-grid-th"
54-
translate="$label().label"
5554
visible="$label().visible"
5655
disable="$label().disabled"
5756
css="setClasses($label())">
57+
<span translate="$label().label"/>
5858
</th>
5959
</tr>
6060
</thead>

app/code/Magento/Bundle/Ui/DataProvider/Product/Form/Modifier/BundlePanel.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -342,9 +342,7 @@ protected function getBundleOptions()
342342
'selection_price_value' => '',
343343
'selection_qty' => '',
344344
],
345-
'links' => [
346-
'insertData' => '${ $.provider }:${ $.dataProvider }'
347-
],
345+
'links' => ['insertData' => '${ $.provider }:${ $.dataProvider }'],
348346
'source' => 'product',
349347
'addButton' => false,
350348
],
@@ -588,10 +586,7 @@ protected function getBundleSelections()
588586
'prefer' => 'radio',
589587
'value' => '0',
590588
'sortOrder' => 50,
591-
'valueMap' => [
592-
'false' => '0',
593-
'true' => '1'
594-
]
589+
'valueMap' => ['false' => '0', 'true' => '1']
595590
],
596591
],
597592
],
@@ -642,7 +637,8 @@ protected function getBundleSelections()
642637
'sortOrder' => 100,
643638
'validation' => [
644639
'required-entry' => true,
645-
'validate-zero-or-greater' => true
640+
'validate-number' => true,
641+
'validate-greater-than-zero' => true
646642
],
647643
'imports' => [
648644
'isInteger' => '${ $.provider }:${ $.parentScope }.selection_qty_is_integer'

app/code/Magento/Bundle/Ui/DataProvider/Product/Form/Modifier/Composite.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public function modifyData(array $data)
120120
'is_default' => ($productLink->getIsDefault()) ? '1' : '0',
121121
'selection_price_value' => $productLink->getPrice(),
122122
'selection_price_type' => $productLink->getPriceType(),
123-
'selection_qty' => (bool)$integerQty ? (int)$productLink->getQty() : $productLink->getQty(),
123+
'selection_qty' => $integerQty ? (int)$productLink->getQty() : $productLink->getQty(),
124124
'selection_can_change_qty' => $productLink->getCanChangeQuantity(),
125125
'selection_qty_is_integer' => (bool)$integerQty,
126126
'position' => $productLink->getPosition(),

app/code/Magento/Bundle/view/adminhtml/web/js/components/bundle-option-qty.js

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,28 @@ define([
1111
return Abstract.extend({
1212
defaults: {
1313
valueUpdate: 'input',
14-
isInteger: true
14+
isInteger: true,
15+
validation: {
16+
'validate-number': true
17+
}
1518
},
1619

1720
/**
18-
* update event
21+
* @inheritdoc
1922
*/
2023
onUpdate: function () {
21-
this.validation['validate-number'] = true;
2224
this.validation['validate-digits'] = this.isInteger;
23-
this.validate();
25+
this._super();
26+
},
27+
28+
/**
29+
* @inheritdoc
30+
*/
31+
hasChanged: function () {
32+
var notEqual = this.value() !== this.initialValue.toString();
33+
34+
return !this.visible() ? false : notEqual;
2435
}
36+
2537
});
2638
});

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ public function update($sku, ProductAttributeMediaGalleryEntryInterface $entry)
9696
foreach ($existingMediaGalleryEntries as $key => $existingEntry) {
9797
if ($existingEntry->getId() == $entry->getId()) {
9898
$found = true;
99+
if ($entry->getFile()) {
100+
$entry->setId(null);
101+
}
99102
$existingMediaGalleryEntries[$key] = $entry;
100103
break;
101104
}

app/code/Magento/Catalog/Test/Unit/Model/Product/Gallery/GalleryManagementTest.php

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ protected function setUp()
4545
{
4646
$this->productRepositoryMock = $this->getMock(\Magento\Catalog\Api\ProductRepositoryInterface::class);
4747
$this->contentValidatorMock = $this->getMock(\Magento\Framework\Api\ImageContentValidatorInterface::class);
48-
$this->productMock = $this->getMock(
48+
$this->productMock = $this->getMock(
4949
\Magento\Catalog\Model\Product::class,
5050
[
5151
'setStoreId',
@@ -115,7 +115,7 @@ public function testCreateWithCannotSaveException()
115115
public function testCreate()
116116
{
117117
$productSku = 'mediaProduct';
118-
$entryContentMock = $this->getMock(
118+
$entryContentMock = $this->getMock(
119119
\Magento\Framework\Api\Data\ImageContentInterface::class
120120
);
121121
$this->mediaGalleryEntryMock->expects($this->any())->method('getContent')->willReturn($entryContentMock);
@@ -153,8 +153,8 @@ public function testUpdateWithNonExistingImage()
153153
$entryId = 42;
154154
$this->productRepositoryMock->expects($this->once())->method('get')->with($productSku)
155155
->willReturn($this->productMock);
156-
$existingEntryMock = $this->getMock(
157-
\Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface::class
156+
$existingEntryMock = $this->getMock(
157+
\Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface::class
158158
);
159159
$existingEntryMock->expects($this->once())->method('getId')->willReturn(43);
160160
$this->productMock->expects($this->once())->method('getMediaGalleryEntries')
@@ -174,8 +174,8 @@ public function testUpdateWithCannotSaveException()
174174
$entryId = 42;
175175
$this->productRepositoryMock->expects($this->once())->method('get')->with($productSku)
176176
->willReturn($this->productMock);
177-
$existingEntryMock = $this->getMock(
178-
\Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface::class
177+
$existingEntryMock = $this->getMock(
178+
\Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface::class
179179
);
180180
$existingEntryMock->expects($this->once())->method('getId')->willReturn($entryId);
181181
$this->productMock->expects($this->once())->method('getMediaGalleryEntries')
@@ -193,13 +193,15 @@ public function testUpdate()
193193
$entryId = 42;
194194
$this->productRepositoryMock->expects($this->once())->method('get')->with($productSku)
195195
->willReturn($this->productMock);
196-
$existingEntryMock = $this->getMock(
197-
\Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface::class
196+
$existingEntryMock = $this->getMock(
197+
\Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface::class
198198
);
199199
$existingEntryMock->expects($this->once())->method('getId')->willReturn($entryId);
200200
$this->productMock->expects($this->once())->method('getMediaGalleryEntries')
201201
->willReturn([$existingEntryMock]);
202202
$entryMock->expects($this->once())->method('getId')->willReturn($entryId);
203+
$entryMock->expects($this->once())->method('getFile')->willReturn("base64");
204+
$entryMock->expects($this->once())->method('setId')->with(null);
203205

204206
$this->productMock->expects($this->once())->method('setMediaGalleryEntries')
205207
->willReturn([$entryMock]);
@@ -217,8 +219,8 @@ public function testRemoveWithNonExistingImage()
217219
$entryId = 42;
218220
$this->productRepositoryMock->expects($this->once())->method('get')->with($productSku)
219221
->willReturn($this->productMock);
220-
$existingEntryMock = $this->getMock(
221-
\Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface::class
222+
$existingEntryMock = $this->getMock(
223+
\Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface::class
222224
);
223225
$existingEntryMock->expects($this->once())->method('getId')->willReturn(43);
224226
$this->productMock->expects($this->once())->method('getMediaGalleryEntries')
@@ -232,8 +234,8 @@ public function testRemove()
232234
$entryId = 42;
233235
$this->productRepositoryMock->expects($this->once())->method('get')->with($productSku)
234236
->willReturn($this->productMock);
235-
$existingEntryMock = $this->getMock(
236-
\Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface::class
237+
$existingEntryMock = $this->getMock(
238+
\Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface::class
237239
);
238240
$existingEntryMock->expects($this->once())->method('getId')->willReturn(42);
239241
$this->productMock->expects($this->once())->method('getMediaGalleryEntries')
@@ -267,8 +269,8 @@ public function testGetWithNonExistingImage()
267269
$imageId = 43;
268270
$this->productRepositoryMock->expects($this->once())->method('get')->with($productSku)
269271
->willReturn($this->productMock);
270-
$existingEntryMock = $this->getMock(
271-
\Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface::class
272+
$existingEntryMock = $this->getMock(
273+
\Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface::class
272274
);
273275
$existingEntryMock->expects($this->once())->method('getId')->willReturn(44);
274276
$this->productMock->expects($this->once())->method('getMediaGalleryEntries')
@@ -282,8 +284,8 @@ public function testGet()
282284
$imageId = 42;
283285
$this->productRepositoryMock->expects($this->once())->method('get')->with($productSku)
284286
->willReturn($this->productMock);
285-
$existingEntryMock = $this->getMock(
286-
\Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface::class
287+
$existingEntryMock = $this->getMock(
288+
\Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface::class
287289
);
288290
$existingEntryMock->expects($this->once())->method('getId')->willReturn(42);
289291
$this->productMock->expects($this->once())->method('getMediaGalleryEntries')

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,7 @@ private function getTierPriceStructure($tierPricePath)
415415
'enabled' => false,
416416
],
417417
'disabled' => false,
418+
'required' => false,
418419
'sortOrder' =>
419420
$this->arrayManager->get($tierPricePath . '/arguments/data/config/sortOrder', $this->meta),
420421
],

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ protected function getOptionsGridConfig($sortOrder)
362362
'collapsibleHeader' => true,
363363
'sortOrder' => $sortOrder,
364364
'dataProvider' => static::CUSTOM_OPTIONS_LISTING,
365-
'links' => ['insertData' => '${ $.provider }:${ $.dataProvider }'],
365+
'imports' => ['insertData' => '${ $.provider }:${ $.dataProvider }'],
366366
],
367367
],
368368
],
@@ -478,8 +478,7 @@ protected function getImportOptionsModalConfig()
478478
'ns' => static::CUSTOM_OPTIONS_LISTING,
479479
'render_url' => $this->urlBuilder->getUrl('mui/index/render'),
480480
'realTimeLink' => true,
481-
'behaviourType' => 'edit',
482-
'externalFilterMode' => true,
481+
'externalFilterMode' => false,
483482
'currentProductId' => $this->locator->getProduct()->getId(),
484483
'dataLinks' => [
485484
'imports' => false,

app/code/Magento/Catalog/view/adminhtml/web/js/components/dynamic-rows-import-custom-options.js

Lines changed: 78 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -4,65 +4,108 @@
44
*/
55

66
define([
7-
'Magento_Ui/js/dynamic-rows/dynamic-rows',
7+
'Magento_Ui/js/dynamic-rows/dynamic-rows-grid',
8+
'underscore',
89
'mageUtils'
9-
], function (DynamicRows, utils) {
10+
], function (DynamicRows, _, utils) {
1011
'use strict';
1112

13+
var maxId = 0,
14+
15+
/**
16+
* Stores max option_id value of the options from recordData once on initialization
17+
* @param {Array} data - array with records data
18+
*/
19+
initMaxId = function (data) {
20+
if (data && data.length) {
21+
maxId = ~~_.max(data, function (record) {
22+
return ~~record['option_id'];
23+
})['option_id'];
24+
}
25+
};
26+
1227
return DynamicRows.extend({
1328
defaults: {
14-
dataProvider: '',
15-
insertData: [],
16-
listens: {
17-
'insertData': 'processingInsertData'
18-
}
29+
mappingSettings: {
30+
enabled: false,
31+
distinct: false
32+
},
33+
update: true,
34+
map: {
35+
'option_id': 'option_id'
36+
},
37+
identificationProperty: 'option_id',
38+
identificationDRProperty: 'option_id'
1939
},
2040

21-
/**
22-
* Calls 'initObservable' of parent
23-
*
24-
* @returns {Object} Chainable.
25-
*/
26-
initObservable: function () {
27-
this._super()
28-
.observe([
29-
'insertData'
30-
]);
41+
/** @inheritdoc */
42+
initialize: function () {
43+
this._super();
44+
initMaxId(this.recordData());
3145

3246
return this;
3347
},
3448

35-
/**
36-
* Parsed data
37-
*
38-
* @param {Array} data - array with data
39-
* about selected records
40-
*/
49+
/** @inheritdoc */
4150
processingInsertData: function (data) {
42-
if (!data.length) {
43-
return false;
44-
}
51+
var options = [],
52+
currentOption;
4553

46-
data.each(function (options) {
47-
options.options.each(function (option) {
48-
var path = this.dataScope + '.' + this.index + '.' + this.recordIterator,
49-
curOption = utils.copy(option);
54+
if (!data) {
55+
return;
56+
}
57+
data.each(function (item) {
58+
if (!item.options) {
59+
return;
60+
}
61+
item.options.each(function (option) {
62+
currentOption = utils.copy(option);
5063

51-
if (curOption.hasOwnProperty('sort_order')) {
52-
delete curOption['sort_order'];
64+
if (currentOption.hasOwnProperty('sort_order')) {
65+
delete currentOption['sort_order'];
5366
}
67+
currentOption['option_id'] = ++maxId;
68+
options.push(currentOption);
69+
});
70+
});
5471

55-
this.source.set(path, curOption);
56-
this.addChild(curOption, false);
57-
}, this);
72+
if (!options.length) {
73+
return;
74+
}
75+
this.cacheGridData = options;
76+
options.each(function (opt) {
77+
this.mappingValue(opt);
5878
}, this);
79+
80+
this.insertData([]);
5981
},
6082

6183
/**
6284
* Set empty array to dataProvider
6385
*/
6486
clearDataProvider: function () {
6587
this.source.set(this.dataProvider, []);
88+
},
89+
90+
/** @inheritdoc */
91+
processingAddChild: function (ctx, index, prop) {
92+
if (ctx && !_.isNumber(ctx['option_id'])) {
93+
ctx['option_id'] = ++maxId;
94+
} else if (!ctx) {
95+
this.showSpinner(true);
96+
this.addChild(ctx, index, prop);
97+
98+
return;
99+
}
100+
101+
this._super(ctx, index, prop);
102+
},
103+
104+
/**
105+
* Mutes parent method
106+
*/
107+
updateInsertData: function () {
108+
return false;
66109
}
67110
});
68111
});

app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/edit/attribute/steps/attributes_values.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
); ?></h2>
1515
<div class="steps-wizard-info">
1616
<span><?php echo $block->escapeHtml(
17-
__('Select values from each attribute to include in this product. Each unique combination of values creates a unigue product SKU.')
17+
__('Select values from each attribute to include in this product. Each unique combination of values creates a unique product SKU.')
1818
);?></span>
1919
</div>
2020
<div data-bind="foreach: attributes, sortableList: attributes">

0 commit comments

Comments
 (0)