-
Notifications
You must be signed in to change notification settings - Fork 89
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
Why don't perform availability check when add item to cart #594
Comments
Good question. |
Actually there is no inventory check throughout the entire API checkout. |
At least in the checkout complete step there should be some kind of validation. Is it not caught by the Sylius internal logic that tries to reserve the items? |
Nope that didn't happen. |
Just noticed this duplicated with #509 |
Any ETA for this bug fix? |
If it is as easy as it seems then it is just adding a validation on some requests. But I want to get @lchrusciel opinion on it as I am not aware of all the ins and outs of Sylius and its stock tracking. |
I already added validation on change quantity request, it working fine. issue with adding new product to cart request validation - we can add validation like above but it will need EXTRA database query for searching products, I personally feel its not good idea, we should add validation on command to save DB query. kindly give your suggestions, i may be wrong |
I haven't considered this but I know that there is a validator for availability what about this one? |
We have to implement this this is request which is currently validated this is handler |
Sounds good. Maybe we can also reuse the validator. |
ya we can reuse validator, i think its better to add validator directly in this is will save double queries |
Well the usual behaviour is to double validate it. Once for the view layer so that the Controller can return a 400 when the product is not in stock and once in the actual logic, which doesn't need to be tied to the shop api using it. |
As @mamazu said. Validation on request to show proper info + on command level an exception. It should be a part of 1.1 |
would #648 be the correct way to fix this issue? |
No, it should be implemented as validator and return validation error instead of 500 critical error. Case: Last item is bought by someone else within browsing session of current customer. He sees outdated catalog and tries to add out of stock item to cart and sees 500 error instead of 400 error |
@diimpp Ok if I look at ProductInCartChannel it seems there exist both a Validator: ShopApiPlugin/src/Resources/config/validation/cart/PutSimpleItemToCartRequest.xml Line 16 in fc87069
and a check in the Handler:
Think then we should do also both in this cases or? |
@alexander-schranz Yes, that would be correct to put check both in handler and in validator. Sorry, I've misread originally, thought it was in Action itself. |
Right now
PutVariantBasedConfigutableItemToCartRequest
only perform very simple checkMay I know is it intentional to leave it availability checking out?
The text was updated successfully, but these errors were encountered: