Skip to content

Commit 2851994

Browse files
authored
Merge pull request #2512 from magento-tango/MAGETWO-88504
MAGETWO-88504: Tiered pricing and quantity Increments do not work with decimal inventory
2 parents c24ad1e + 7ee7971 commit 2851994

File tree

6 files changed

+23
-7
lines changed

6 files changed

+23
-7
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,8 @@ private function getTierPriceStructure($tierPricePath)
500500
'validation' => [
501501
'required-entry' => true,
502502
'validate-greater-than-zero' => true,
503-
'validate-digits' => true,
503+
'validate-digits' => false,
504+
'validate-number' => true,
504505
],
505506
],
506507
],

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ protected function customizeAdvancedPriceFormat(array $data)
106106
$value[ProductAttributeInterface::CODE_TIER_PRICE_FIELD_PRICE] =
107107
$this->formatPrice($value[ProductAttributeInterface::CODE_TIER_PRICE_FIELD_PRICE]);
108108
$value[ProductAttributeInterface::CODE_TIER_PRICE_FIELD_PRICE_QTY] =
109-
(int)$value[ProductAttributeInterface::CODE_TIER_PRICE_FIELD_PRICE_QTY];
109+
(float) $value[ProductAttributeInterface::CODE_TIER_PRICE_FIELD_PRICE_QTY];
110110
}
111111
}
112112

app/code/Magento/CatalogInventory/Model/Stock/Item.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,8 @@ public function getQtyIncrements()
401401
if ($this->getUseConfigQtyIncrements()) {
402402
$this->qtyIncrements = $this->stockConfiguration->getQtyIncrements($this->getStoreId());
403403
} else {
404-
$this->qtyIncrements = (int) $this->getData(static::QTY_INCREMENTS);
404+
$qtyIncrements = $this->getData(static::QTY_INCREMENTS);
405+
$this->qtyIncrements = $this->getIsQtyDecimal() ? (float) $qtyIncrements : (int) $qtyIncrements;
405406
}
406407
}
407408
if ($this->qtyIncrements <= 0) {

app/code/Magento/CatalogInventory/Model/Stock/StockItemRepository.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
use Magento\CatalogInventory\Api\Data\StockItemInterface;
1111
use Magento\CatalogInventory\Api\Data\StockItemInterfaceFactory;
1212
use Magento\CatalogInventory\Api\StockConfigurationInterface;
13-
use Magento\CatalogInventory\Api\StockItemRepositoryInterface as StockItemRepositoryInterface;
13+
use Magento\CatalogInventory\Api\StockItemRepositoryInterface;
1414
use Magento\CatalogInventory\Model\Indexer\Stock\Processor;
1515
use Magento\CatalogInventory\Model\ResourceModel\Stock\Item as StockItemResource;
1616
use Magento\CatalogInventory\Model\Spi\StockStateProviderInterface;

app/code/Magento/CatalogInventory/Test/Unit/Model/Stock/ItemTest.php

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,7 @@ public function testGetQtyIncrements($config, $expected)
394394
$this->setDataArrayValue('qty_increments', $config['qty_increments']);
395395
$this->setDataArrayValue('enable_qty_increments', $config['enable_qty_increments']);
396396
$this->setDataArrayValue('use_config_qty_increments', $config['use_config_qty_increments']);
397+
$this->setDataArrayValue('is_qty_decimal', $config['is_qty_decimal']);
397398
if ($config['use_config_qty_increments']) {
398399
$this->stockConfiguration->expects($this->once())
399400
->method('getQtyIncrements')
@@ -415,26 +416,38 @@ public function getQtyIncrementsDataProvider()
415416
[
416417
'qty_increments' => 1,
417418
'enable_qty_increments' => true,
418-
'use_config_qty_increments' => true
419+
'use_config_qty_increments' => true,
420+
'is_qty_decimal' => false
419421
],
420422
1
421423
],
422424
[
423425
[
424426
'qty_increments' => -2,
425427
'enable_qty_increments' => true,
426-
'use_config_qty_increments' => true
428+
'use_config_qty_increments' => true,
429+
'is_qty_decimal' => false
427430
],
428431
false
429432
],
430433
[
431434
[
432435
'qty_increments' => 3,
433436
'enable_qty_increments' => true,
434-
'use_config_qty_increments' => false
437+
'use_config_qty_increments' => false,
438+
'is_qty_decimal' => false
435439
],
436440
3
437441
],
442+
[
443+
[
444+
'qty_increments' => 0.5,
445+
'enable_qty_increments' => true,
446+
'use_config_qty_increments' => false,
447+
'is_qty_decimal' => true
448+
],
449+
0.5
450+
],
438451
];
439452
}
440453

app/code/Magento/CatalogInventory/view/adminhtml/web/js/components/qty-validator-changer.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ define([
2020
var isDigits = value !== 1;
2121

2222
this.validation['validate-integer'] = isDigits;
23+
this.validation['validate-digits'] = isDigits;
2324
this.validation['less-than-equals-to'] = isDigits ? 99999999 : 99999999.9999;
2425
this.validate();
2526
}

0 commit comments

Comments
 (0)