Skip to content

Commit 46319f3

Browse files
committed
MAGETWO-55847: [GitHub] When tier price qty above 1000 adds a thousand separator in the Admin Panel #5745
2 parents c2a4d83 + 9d33182 commit 46319f3

File tree

7 files changed

+42
-71
lines changed

7 files changed

+42
-71
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/Catalog/Ui/DataProvider/Product/Form/Modifier/General.php

Lines changed: 6 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@
99
use Magento\Catalog\Model\Locator\LocatorInterface;
1010
use Magento\Ui\Component\Form;
1111
use Magento\Framework\Stdlib\ArrayManager;
12-
use Magento\Store\Model\StoreManagerInterface;
1312
use Magento\Framework\Locale\CurrencyInterface;
1413

1514
/**
1615
* Data provider for main panel of product page
16+
*
17+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1718
*/
1819
class General extends AbstractModifier
1920
{
@@ -26,11 +27,6 @@ class General extends AbstractModifier
2627
* @var ArrayManager
2728
*/
2829
protected $arrayManager;
29-
30-
/**
31-
* @var StoreManagerInterface
32-
*/
33-
private $storeManager;
3430

3531
/**
3632
* @var CurrencyInterface
@@ -82,7 +78,7 @@ protected function customizeWeightFormat(array $data)
8278
$data = $this->arrayManager->replace(
8379
$path,
8480
$data,
85-
$this->formatNumber($this->arrayManager->get($path, $data))
81+
$this->formatWeight($this->arrayManager->get($path, $data))
8682
);
8783
}
8884

@@ -105,7 +101,7 @@ protected function customizeAdvancedPriceFormat(array $data)
105101
$value[ProductAttributeInterface::CODE_TIER_PRICE_FIELD_PRICE] =
106102
$this->formatPrice($value[ProductAttributeInterface::CODE_TIER_PRICE_FIELD_PRICE]);
107103
$value[ProductAttributeInterface::CODE_TIER_PRICE_FIELD_PRICE_QTY] =
108-
$this->formatNumber((int)$value[ProductAttributeInterface::CODE_TIER_PRICE_FIELD_PRICE_QTY]);
104+
(int)$value[ProductAttributeInterface::CODE_TIER_PRICE_FIELD_PRICE_QTY];
109105
}
110106
}
111107

@@ -378,23 +374,6 @@ private function getLocaleCurrency()
378374
return $this->localeCurrency;
379375
}
380376

381-
/**
382-
* The getter function to get the store manager for real application code
383-
*
384-
* @return \Magento\Store\Model\StoreManagerInterface
385-
*
386-
* @deprecated
387-
*/
388-
private function getStoreManager()
389-
{
390-
if ($this->storeManager === null) {
391-
$this->storeManager =
392-
\Magento\Framework\App\ObjectManager::getInstance()->get(StoreManagerInterface::class);
393-
}
394-
return $this->storeManager;
395-
}
396-
397-
398377
/**
399378
* Format price according to the locale of the currency
400379
*
@@ -407,7 +386,7 @@ protected function formatPrice($value)
407386
return null;
408387
}
409388

410-
$store = $this->getStoreManager()->getStore();
389+
$store = $this->locator->getStore();
411390
$currency = $this->getLocaleCurrency()->getCurrency($store->getBaseCurrencyCode());
412391
$value = $currency->toCurrency($value, ['display' => \Magento\Framework\Currency::NO_SYMBOL]);
413392

@@ -428,7 +407,7 @@ protected function formatNumber($value)
428407

429408
$value = (float)$value;
430409
$precision = strlen(substr(strrchr($value, "."), 1));
431-
$store = $this->getStoreManager()->getStore();
410+
$store = $this->locator->getStore();
432411
$currency = $this->getLocaleCurrency()->getCurrency($store->getBaseCurrencyCode());
433412
$value = $currency->toCurrency($value, ['display' => \Magento\Framework\Currency::NO_SYMBOL,
434413
'precision' => $precision]);

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)