fix: allow bundle product with only non-required options to be added …#40577
Open
baudeval wants to merge 4 commits intomagento:2.4-developfrom
Open
fix: allow bundle product with only non-required options to be added …#40577baudeval wants to merge 4 commits intomagento:2.4-developfrom
baudeval wants to merge 4 commits intomagento:2.4-developfrom
Conversation
|
Hi @baudeval. Thank you for your contribution!
Allowed build names are:
You can find more information about the builds here For more details, review the Code Contributions documentation. |
Contributor
Author
|
@magento run all tests |
30644ba to
a9090f9
Compare
Contributor
Author
|
@magento run all tests |
…to cart Resolves magento#40573 - Bundle products with no required options were incorrectly blocked with "Please specify product option(s)." error. Added bundleHasRequiredOptions() check before throwing the exception when no options are selected.
c1395fb to
964cff5
Compare
Contributor
Author
|
@magento run all tests |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…to cart
Resolves #40573 - Bundle products with no required options were incorrectly blocked with "Please specify product option(s)." error. Added bundleHasRequiredOptions() check before throwing the exception when no options are selected.
Description (*)
When a bundle product has only non-required options, adding it to the cart without selecting any option throws the error "Please specify product option(s).".
The root cause is in
_prepareProduct()insideMagento\Bundle\Model\Product\Type: when$optionIdsis empty and strict process mode is active, the exception is thrown unconditionally — without checking whether any option is actually required.This PR adds a
bundleHasRequiredOptions()private method that checks if the bundle has at least one required option before throwing the exception. If no options are required, the bundle is allowed to be added to the cart without any selection.Changes:
bundleHasRequiredOptions()private method toMagento\Bundle\Model\Product\Typeempty($optionIds) && $isStrictProcessModecheck to only throw when required options existRelated Pull Requests
Fixed Issues (if relevant)
Manual testing scenarios (*)
Create a bundle product with only non-required options (all options have
Requiredset toNo)Add at least one selection to each option
Navigate to the bundle product page on the storefront
Click Add to Cart without selecting any option
Expected: The product is added to the cart successfully
Actual (before fix): Error message "Please specify product option(s)." is displayed
Create a bundle product with at least one required option
Navigate to the product page and click Add to Cart without selecting any option
Expected: Error message "Please specify product option(s)." is displayed (existing behavior preserved)
...
...
Questions or comments
Contribution checklist (*)