From 3fc107ad5426ccf73566d562cf643c9e94e27d5b Mon Sep 17 00:00:00 2001 From: Lewis Voncken Date: Sat, 6 Oct 2018 18:12:27 +0200 Subject: [PATCH 1/2] [BACKPORT] type casted $qty to float in \Magento\Catalog\Model\Product::setQty() --- app/code/Magento/Catalog/Model/Product.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Catalog/Model/Product.php b/app/code/Magento/Catalog/Model/Product.php index e4dacf275fc9b..b5e0a2c0f48b6 100644 --- a/app/code/Magento/Catalog/Model/Product.php +++ b/app/code/Magento/Catalog/Model/Product.php @@ -972,7 +972,7 @@ public function afterSave() public function setQty($qty) { if ($this->getData('qty') != $qty) { - $this->setData('qty', $qty); + $this->setData('qty', (float)$qty); $this->reloadPriceInfo(); } return $this; @@ -985,7 +985,7 @@ public function setQty($qty) */ public function getQty() { - return $this->getData('qty'); + return (float)$this->getData('qty'); } /** From fa529366822a4e049ddcab820212af24ee931c2b Mon Sep 17 00:00:00 2001 From: Oleksii Korshenko Date: Fri, 19 Oct 2018 14:02:30 -0500 Subject: [PATCH 2/2] Issue magento/magento2#18094: Should getQty() return int/float or string - remove typecasting from the setter --- app/code/Magento/Catalog/Model/Product.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Catalog/Model/Product.php b/app/code/Magento/Catalog/Model/Product.php index b5e0a2c0f48b6..8a9233f176c61 100644 --- a/app/code/Magento/Catalog/Model/Product.php +++ b/app/code/Magento/Catalog/Model/Product.php @@ -972,7 +972,7 @@ public function afterSave() public function setQty($qty) { if ($this->getData('qty') != $qty) { - $this->setData('qty', (float)$qty); + $this->setData('qty', $qty); $this->reloadPriceInfo(); } return $this;