diff --git a/app/code/Magento/CatalogInventory/Api/StockConfigurationInterface.php b/app/code/Magento/CatalogInventory/Api/StockConfigurationInterface.php index 767625e9f3489..a23d5030b8242 100644 --- a/app/code/Magento/CatalogInventory/Api/StockConfigurationInterface.php +++ b/app/code/Magento/CatalogInventory/Api/StockConfigurationInterface.php @@ -77,7 +77,7 @@ public function getEnableQtyIncrements($storeId = null); /** * @param int $storeId - * @return int + * @return float */ public function getQtyIncrements($store = null); diff --git a/app/code/Magento/CatalogInventory/Model/Configuration.php b/app/code/Magento/CatalogInventory/Model/Configuration.php index 06cfde0b7d247..2f0415b40dc01 100644 --- a/app/code/Magento/CatalogInventory/Model/Configuration.php +++ b/app/code/Magento/CatalogInventory/Model/Configuration.php @@ -273,7 +273,7 @@ public function getEnableQtyIncrements($store = null) /** * @param null|string|bool|int|\Magento\Store\Model\Store $store - * @return int + * @return float */ public function getQtyIncrements($store = null) { diff --git a/app/code/Magento/CatalogInventory/Model/Stock/Item.php b/app/code/Magento/CatalogInventory/Model/Stock/Item.php index b4b70041ce148..bcab2c622a5bc 100644 --- a/app/code/Magento/CatalogInventory/Model/Stock/Item.php +++ b/app/code/Magento/CatalogInventory/Model/Stock/Item.php @@ -392,7 +392,7 @@ public function getUseConfigQtyIncrements() /** * Retrieve Quantity Increments * - * @return int|false + * @return int|float|false */ public function getQtyIncrements() { @@ -401,7 +401,13 @@ public function getQtyIncrements() if ($this->getUseConfigQtyIncrements()) { $this->qtyIncrements = $this->stockConfiguration->getQtyIncrements($this->getStoreId()); } else { - $this->qtyIncrements = (int) $this->getData(static::QTY_INCREMENTS); + $this->qtyIncrements = $this->getData(static::QTY_INCREMENTS); + } + + if ($this->getIsQtyDecimal()) { // Cast accordingly to decimal qty usage + $this->qtyIncrements = (float) $this->qtyIncrements; + } else { + $this->qtyIncrements = (int) $this->qtyIncrements; } } if ($this->qtyIncrements <= 0) { diff --git a/app/code/Magento/CatalogInventory/Test/Unit/Model/Stock/ItemTest.php b/app/code/Magento/CatalogInventory/Test/Unit/Model/Stock/ItemTest.php index bbc7823b13e01..e63a573b2f3a4 100644 --- a/app/code/Magento/CatalogInventory/Test/Unit/Model/Stock/ItemTest.php +++ b/app/code/Magento/CatalogInventory/Test/Unit/Model/Stock/ItemTest.php @@ -394,6 +394,7 @@ public function testGetQtyIncrements($config, $expected) $this->setDataArrayValue('qty_increments', $config['qty_increments']); $this->setDataArrayValue('enable_qty_increments', $config['enable_qty_increments']); $this->setDataArrayValue('use_config_qty_increments', $config['use_config_qty_increments']); + $this->setDataArrayValue('is_qty_decimal', $config['is_qty_decimal']); if ($config['use_config_qty_increments']) { $this->stockConfiguration->expects($this->once()) ->method('getQtyIncrements') @@ -415,7 +416,26 @@ public function getQtyIncrementsDataProvider() [ 'qty_increments' => 1, 'enable_qty_increments' => true, - 'use_config_qty_increments' => true + 'use_config_qty_increments' => true, + 'is_qty_decimal' => false, + ], + 1 + ], + [ + [ + 'qty_increments' => 1.5, + 'enable_qty_increments' => true, + 'use_config_qty_increments' => true, + 'is_qty_decimal' => true, + ], + 1.5 + ], + [ + [ + 'qty_increments' => 1.5, + 'enable_qty_increments' => true, + 'use_config_qty_increments' => true, + 'is_qty_decimal' => false, ], 1 ], @@ -423,7 +443,8 @@ public function getQtyIncrementsDataProvider() [ 'qty_increments' => -2, 'enable_qty_increments' => true, - 'use_config_qty_increments' => true + 'use_config_qty_increments' => true, + 'is_qty_decimal' => false, ], false ], @@ -431,7 +452,8 @@ public function getQtyIncrementsDataProvider() [ 'qty_increments' => 3, 'enable_qty_increments' => true, - 'use_config_qty_increments' => false + 'use_config_qty_increments' => false, + 'is_qty_decimal' => false, ], 3 ], diff --git a/app/code/Magento/CatalogInventory/view/adminhtml/ui_component/product_form.xml b/app/code/Magento/CatalogInventory/view/adminhtml/ui_component/product_form.xml index 3472f4368d617..64015e87e7d99 100644 --- a/app/code/Magento/CatalogInventory/view/adminhtml/ui_component/product_form.xml +++ b/app/code/Magento/CatalogInventory/view/adminhtml/ui_component/product_form.xml @@ -568,7 +568,6 @@ [GLOBAL] - true true