-
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
Product->save() shouldn't be called directly #8498
Conversation
Here is a problem with calling Product->save() directly: When product has custom options it should have 'has_options' and possibly 'required_options' set to true but calling Product->save() without $product->setCanSaveCustomOptions(true); will result in both 'has_options' and 'required_options' to be set to false. Also calling $product->save() won't invalidate internal ProductRepository's cache (instances , instancesById) and this would produces other unexpected issues.
@stansm Thanks you, change looks good. |
@vrann ok, I'll do it this weekend |
@stansm please verify this bug report. Is that what you had in mind? Steps to Reproduce
Expected result: Actual result: |
@stansm please verify steps and I'll merge pull request upon manual verification. You are welcome to add tests as a separate pull request though! |
@vrann Instead of 4 I've just had a code like:
and after it executed 'has_options' and 'required_options' were set to false on this product (I've traced it and that's how it should really be according to the logic in the Product::beforeSave). And even that 'has_options' and 'required_options' were gone, custom options were still showing on a product page but were missing when added to the cart. This is what I know for now.. |
@stansm thank you, that is probably same the flow but from the code perspective. I reproduced the issue using the steps to reproduce. |
…_25082023 Hammer platform health scope 25082023
Here is a problem with calling Product->save() directly in ProductWebsiteLinkRepository:
When product has custom options it should have 'has_options' and possibly 'required_options' set to true but calling Product->save() without $product->setCanSaveCustomOptions(true); will result in both 'has_options' and 'required_options' to be set to false.
Also calling $product->save() won't invalidate internal ProductRepository's cache (instances , instancesById) and this would produces other unexpected issues.