-
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
Shipping method estimation loads all customer's quotes #9744
Comments
Experienced this error myself, with similar findings. Pretty sure I wrote about it somewhere, but cannot find it now.
Yes, please. I'll take that, plus, independently, a fix for the underlying error. Underlying error can probably be fixed by simply adding a foreign key constraint in between cart item and product entity tables, preferably with an "ON DELETE CASCADE" =) |
Hi, we're having the same issue and can possible shed some light. The error occurs because although there are quotes for the user they all have is_active = 0. I'm not sure why they have so many quotes though and would have expected them to be removed. The query that is run when trying to get the quote from within Magento\Quote\Model\Webapi\ParamOverriderCartId is
So it's always trying to get the latest quote but as non are active, then it doesn't' return any for this user. The error always happens after making a purchase and then added products to the cart in the same session. If you logout and back in a new active quote is created. |
Has anyone found a workaround for this? |
I am also experiencing this issue on Magento 2.1.7. First checkout after login is fine, second checkout attempt results in the 'cartId is a required field' error. Any assistance would be greatly appreciated. |
This is still present in Magento 2.1.7 occurs on 2nd checkout for logged in user only for us, using steps described above. |
@sydekumf, thank you for your report. |
Hi, I do not have any other steps to reproduce. Maybe ask the other guys who can reproduce it, if they can add any further information?
I think there should be a better approach to this, not just hiding exceptions... |
Same problem in 2.1.8 EE. Occurs on 2nd checkout for logged in user, using steps described above. |
@magento-engcom-team If you need credentials to a Magento 2 installation experiencing this issue, let me know. |
Per multiple requests – reopening this for the further investigation. |
Foreign key is implemented programmatically in this specific case, please refer to magento2/app/code/Magento/Quote/Model/Product/QuoteItemsCleaner.php Lines 26 to 32 in 78e72eb
|
The correct link is: magento2/app/code/Magento/Quote/Model/Product/QuoteItemsCleaner.php Lines 26 to 32 in 78e72eb
|
@wget Thank you for pointing out. Comment updated. |
Also encountered this issue. Seems that |
I can reproduce this issue with the following steps on 2.1.8 CE. This is rather easy.
This is pretty normal I get this error in this particular (silly) use case (even if a more straightforward error message should be displayed), I'm not discussing on this one. But I have to admit, when not being silly, I got this error message by doing other steps and by switching from one payment method to the other etc. The investigation goes on on my side as now I'm not able to reproduce (got the error one time in the afternoon though). I will update you when I can find the exact steps to reproduce it completely. |
@wget Thank you for the update. |
@magento-engcom-team Thanks for the precision, but like I wrote, I'm actually using the Community Edition (2.1.8 CE). |
We are getting the same issue with Magento CE 2.1.9. The reason we get this issue is, that the checkout loads another (older) quote for the customer which is still active. Since the quotes are ordered by updated_at DESC it loads the older one, since the new one has "00-00-0000 00:00:00" as updated_at. The older quote contains a product which is no longer present, so the quote can't be loaded, the %cart_id% can't be replaced (due to NoSuchEntityException) and we are getting the error cartId is required. So our customer has multiple active quotes. Why can this happen? |
I've solved following this steps: Now i can make several orders without logout, and all cart strange behaviour has dissappeared. |
I think I understand the problem now with the Thanks :-) |
I've seen it happen on CE as well.
Well, obviously, whatever that thing is - it's not working. Is there a particular reason why it was implemented that way? Such an approach seems quite fragile, at best. (i.e. why couldn't you just add this constraint, as several people above suggest?)
Why would it "influence/fix particular problem"? No-one said that, that would be nonsense. The point is that exception masking hides the original exception, ignores invalid application state, making it much harder to trace and debug the code and identify the real root cause behind the second exception which appears elsewhere and seems quite cryptic. In this particular case it's even worse: the exception throw+catch are used as a control structure in order to pass information (exception is explicitly said to be an "okay" behavior in comments) which is none better then using Obviously, exception handling is a separate issue and should be handled independently as there are many other offending pieces of code just like the one referenced here (although this one is the most annoying), but it shouldn't be forgotten and ignored neither, wouldn't you agree? |
So there is one thing we did to fix this problem for ever: ALTER TABLE quote
CHANGE updated_at
updated_at TIMESTAMP NOT NULL
DEFAULT CURRENT_TIMESTAMP
ON UPDATE CURRENT_TIMESTAMP; For a fresh insert the |
It's implemented this way as Magento Commerce Edition uses different approach to clean up.
It is possible that adding a constraint on your own will now have any negative consequences. However, there is no guarantee, only testing can confirm. |
Hello again @magento-engcom-team As far as I can see, you've only addressed one of the issues brought up in this issue report with your comments.
Handling any of those should IMHO significantly reduce the overall level of pain brought by this issue. |
#WroCD |
Similar or identical github issues for this same error: All related, tried every solution on all pages and still have the issue, including @sydekumf solution here: Issue MAGETWO-84524 is tracking it to some degree and still isn't fixed in Magento 2.3 How is this the most popular ecommerce store in the US if it doesn't even have a functioning checkout. This happens for me using authnet directpost regardless of what I do, guest checkout, or new, using stored address, or not. Only the error message will change at times, but it's always one of the error messages given in the links above. Issue is as described, there is a quote_id in the quote table but it is not active. If I switch it manually to be active then it has duplicate foreign key when trying to replace the order. With active set to 0, get the cartId error. The only solution anyone seems to say works 100% is buying a 3rd part module to do authorize.net payments which seems absurd, as paypal also doesn't work, citing invoice id errors. |
Hi @engcom-Delta. Thank you for working on this issue.
|
Hi @SoloDevAtrix @sydekumf, thank you for your reports. I am not able to reproduce issue by steps you described on clean 2.4-develop And exception under Please feel free to comment, reopen or create new ticket according to the Issue reporting guidelines |
Preconditions
Magento 2.1.7
When you enter the checkout Magento tries to estimate the shipping method and costs. Therefore it loads available quotes with this logic:
Magento\Quote\Model\QuoteRepository::getForCustomer()
. For some reason it tries to load all quotes available for this customer, even quotes which are no longer active or whose products do not longer exist.This leads to an exception in
Magento\Quote\Model\ResourceModel\Quote\Item\Collection::_assignProducts()
where it tries to assign the not existing products. The exception is hidden because of this inMagento\Quote\Model\Webapi\ParamOverriderCartId
:In the frontend it leads to another error which has nothing to do with this error: #1443
I am not sure what is the correct behavior:
Steps to reproduce
Expected result
Actual result
The text was updated successfully, but these errors were encountered: