Skip to content

FIX for MSI issue #74 on qty increment #14806

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public function getEnableQtyIncrements($storeId = null);

/**
* @param int $storeId
* @return int
* @return float
*/
public function getQtyIncrements($store = null);

Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/CatalogInventory/Model/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
10 changes: 8 additions & 2 deletions app/code/Magento/CatalogInventory/Model/Stock/Item.php
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ public function getUseConfigQtyIncrements()
/**
* Retrieve Quantity Increments
*
* @return int|false
* @return int|float|false
*/
public function getQtyIncrements()
{
Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -415,23 +416,44 @@ 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
],
[
[
'qty_increments' => -2,
'enable_qty_increments' => true,
'use_config_qty_increments' => true
'use_config_qty_increments' => true,
'is_qty_decimal' => false,
],
false
],
[
[
'qty_increments' => 3,
'enable_qty_increments' => true,
'use_config_qty_increments' => false
'use_config_qty_increments' => false,
'is_qty_decimal' => false,
],
3
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,6 @@
<settings>
<scopeLabel>[GLOBAL]</scopeLabel>
<validation>
<rule name="validate-digits" xsi:type="boolean">true</rule>
<rule name="validate-number" xsi:type="boolean">true</rule>
</validation>
<label translate="true">Qty Increments</label>
Expand Down