-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
Set minimum qty 1 after cast to int #21928
Set minimum qty 1 after cast to int #21928
Conversation
Hi @likemusic. Thank you for your contribution
For more details, please, review the Magento Contributor Assistant documentation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @likemusic,
thank you for your contribution!
Could you please check the minor CR recommendations?
Thank you!
@magento-engcom-team give me test instance |
Hi @dmytro-ch. Thank you for your request. I'm working on Magento instance for you |
Hi @dmytro-ch, here is your new Magento instance. |
@magento-engcom-team give me test instance |
Hi @dmytro-ch. Thank you for your request. I'm working on Magento instance for you |
Hi @dmytro-ch, here is your new Magento instance. |
@magento-engcom-team give me test instance |
Hi @dmytro-ch. Thank you for your request. I'm working on Magento instance for you |
Hi @dmytro-ch, here is your new Magento instance. |
Hi @dmytro-ch, thank you for the review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@likemusic please simplify implementation even more and squash changes into a single commit.
@@ -119,13 +119,13 @@ public function checkQuoteItemQty(StockItemInterface $stockItem, $qty, $summaryQ | |||
$result->setItemIsQtyDecimal($stockItem->getIsQtyDecimal()); | |||
if (!$stockItem->getIsQtyDecimal()) { | |||
$result->setHasQtyOptionUpdate(true); | |||
$qty = (int) $qty; | |||
$qty = (int) $qty ?: 1; | |||
/** | |||
* Adding stock data to quote item | |||
*/ | |||
$result->setItemQty($qty); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$result->setItemQty($qty); | |
$result->setItemQty((int)$qty ?: 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@orlangur $qty
variable used below in file many times. I think it should contain already fixed value, isn't it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@likemusic it is casted to int only here within condition. Please don't forget to squash.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@orlangur I think all other validation should by with casted value.
Assume $qty = 0.1 and $stockItem->getMinSaleQty() is 1. In $result we have 1.
Look at line 130 if ($stockItem->getMinSaleQty() && $qty < $stockItem->getMinSaleQty()) {
If here $qty == 1 will not add error message to $result. If $qty == 0.1 here, we will add error message to $result.
In latest case finaly we will have result with $qty = 1 but with massage that 'The fewest you may purchase is 1.'. It's not logical. Imho all validation with $qty variable in this method should be done with cased to int value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@likemusic ok, agree, assignment should still be there and $result->setItemQty($qty = (int)$qty ?: 1);
would look awkward.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made:
git rebase -i 2.3-develop
git push -f
Is it right way to squash commits in pull-request?
$qty = $this->getNumber($qty); | ||
$origQty = (int) $origQty; | ||
$origQty = $this->getNumber($origQty); | ||
$origQty = (int) $origQty ?: 1; | ||
$result->setOrigQty($origQty); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$result->setOrigQty($origQty); | |
$result->setOrigQty((int)$this->getNumber($origQty) ?: 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@likemusic great! This is exactly what was needed.
Hi @orlangur, thank you for the review. |
@magento-engcom-team give me test instance |
Hi @VasylShvorak. Thank you for your request. I'm working on Magento instance for you |
Hi @VasylShvorak, here is your new Magento instance. |
✔️ QA passed |
Hi @likemusic, thank you for your contribution! |
Release note" Catalog Magento no longer throws a divide by zero exception if a product configuration specifies the Minimum Qty Allowed in Shopping Cart as a decimal value less than one, and sets the Qty Uses Decimals attribute to |
Description (*)
Set minimum qty 1 for values casted to int from float value.
Fixed Issues (if relevant)
Manual testing scenarios (*)
Contribution checklist (*)