Skip to content

Commit 4ecd6e8

Browse files
Merge pull request #316 from magento-firedrakes/bugfixes
Fixed issues: - MAGETWO-57397: Update gallery entry via API doesn't work - for mainline - MAGETWO-51169: Last Wizard step Button has incorrect label - MAGETWO-52280: "Tier Price" field is unexpectedly marked as required on "create Product" Admin page - MAGETWO-54176: Wrong quantity validation for bundle option lines - MAGETWO-54247: Typo on Create Product Configurations Slideout
2 parents d0495a9 + 35222d1 commit 4ecd6e8

File tree

6 files changed

+36
-44
lines changed

6 files changed

+36
-44
lines changed

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/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/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">

app/code/Magento/Ui/view/base/web/js/lib/step-wizard.js

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ define([
99
'jquery',
1010
'underscore',
1111
'ko',
12-
'mage/backend/notification'
12+
'mage/backend/notification',
13+
'mage/translate'
1314
], function (uiRegistry, Component, $, _, ko) {
1415
'use strict';
1516

@@ -28,24 +29,13 @@ define([
2829
this.steps = steps;
2930
this.index = 0;
3031
this.data = {};
31-
this.nextLabelText = 'Next';
32-
this.prevLabelText = 'Back';
33-
this.initSelectors = function (modalClass) {
34-
var elementSelector = '[data-role=steps-wizard-main]';
35-
36-
this.nextLabel = '[data-role="step-wizard-next"]';
37-
this.prevLabel = '[data-role="step-wizard-prev"]';
38-
39-
if (modalClass) {
40-
this.nextLabel = '.' + modalClass + ' ' + this.nextLabel;
41-
this.prevLabel = '.' + modalClass + ' ' + this.prevLabel;
42-
elementSelector = '.' + modalClass + elementSelector;
43-
}
44-
45-
this.element = $(elementSelector);
46-
$(this.element).notification();
47-
};
48-
this.initSelectors(modalClass);
32+
this.nextLabelText = $.mage.__('Next');
33+
this.prevLabelText = $.mage.__('Back');
34+
this.elementSelector = '[data-role=steps-wizard-main]';
35+
this.element = modalClass ? $('.' + modalClass + this.elementSelector) : $(this.elementSelector);
36+
this.nextLabel = '[data-role="step-wizard-next"]';
37+
this.prevLabel = '[data-role="step-wizard-prev"]';
38+
this.element.notification();
4939
this.move = function (newIndex) {
5040
if (!this.preventSwitch(newIndex)) {
5141
if (newIndex > this.index) {

0 commit comments

Comments
 (0)