-
Notifications
You must be signed in to change notification settings - Fork 4
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
[BUG] Adding another project to cart fails if there's one in the cart already with qty = 1 #9
Comments
The method called here saves the quote. That's where it then fails. |
I'm not quite sure what would be a good way to fix this. Maybe plugging a different method than |
Wondering why it still fails to add product B, even the exception is caught ... |
Maybe because the exception rewinds the transaction? |
You mean the exception rewineded the transaction before getting caught -- possible. |
No, the actual exception gets re-thrown a couple of times. I think it originally happens here and gets rolled back: https://github.com/magento/magento2/blob/2.4-develop/lib/internal/Magento/Framework/Model/ResourceModel/Db/AbstractDb.php#L433 |
Uncommenting the |
I'm actually not quite sure why magento tries to add all existing products to cart when saving the cart (at vendor/magento/module-quote/Model/Quote.php:1804) |
I think if we could manage to set EDIT: Okay upon second look it seems like this is already fixed in the newest magento version? The last part looks like this in the source on github:
and in the version we're using it does not have that |
Okay it does work when I edit the source at that place here to contain the if. |
This is the commit that fixes it: magento/magento2@5478c03 |
It looks like adding magento/magento2@5478c03 via composer patches fixes this issue. @schmengler @lbuchholz since there's no magento version yet with the patch it might make sense to add a note to the readme about a patch being necessary? Or patch it in the module directly? There's probably other places as well where this bug is triggered but it looks a lot like an issue with this module (even though it is not, but we'd never noticed that bug without using this). |
Adding a product (Let's call it "product a") to cart with qty = 1 works fine. But when I then want to add another product ("product B") to the cart with some other qty, adding that second product fails with an error message "The requested qty is not available".
This is the quantity settings of product A:
Product B has some some quantity > 1. Adding it individually (without Product A already in cart) works fine.
I dug into it a bit and it looks like this happens because this module saves the cart. That tries to set the quantity again for product A which won't work because it does not have enough quantity available at this point. Not quite sure if this is a core issue or only related to this module.
The text was updated successfully, but these errors were encountered: