-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Bundle products options input validation #29256
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
Bundle products options input validation #29256
Conversation
Hi @michalderlatka. Thank you for your contribution
❗ Automated tests can be triggered manually with an appropriate comment:
You can find more information about the builds here ℹ️ Please run only needed test builds instead of all when developing. Please run all test builds before sending your PR for review. For more details, please, review the Magento Contributor Guide documentation. 🕙 You can find the schedule on the Magento Community Calendar page. 📞 The triage of Pull Requests happens in the queue order. If you want to speed up the delivery of your contribution, please join the Community Contributions Triage session to discuss the appropriate ticket. 🎥 You can find the recording of the previous Community Contributions Triage on the Magento Youtube Channel ✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel |
@magento run all tests |
59d831a
to
71bdba5
Compare
@magento run all tests |
* @return void | ||
* @throws \Magento\Framework\Exception\LocalizedException | ||
*/ | ||
protected function validateRadioAndSelectOptions($optionsCollection, $options): void |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't add protected, use private
|
||
if (is_array($optionsCollection->getItems())) { | ||
foreach ($optionsCollection->getItems() as $option) { | ||
if (($option->getType() == 'radio' || $option->getType() == 'select') && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that is a big condition, can you move that to a method with a meaningful name?
/** | ||
* Validate Options for Radio and Select input types | ||
* | ||
* @param \Magento\Bundle\Model\ResourceModel\Option\Collection $optionsCollection |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do "use Magento\Bundle\Model\ResourceModel\Option\Collection" and only use "Collection"
Hi @michalderlatka . Nice to see another contributor from Poland. |
71bdba5
to
28e20d9
Compare
@magento run all tests |
@magento run static tests |
@magento run all tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some static fails, but also some possible performance problems:
PHP Code Sniffer detected 2 violation(s):
FILE: /var/www/html/app/code/Magento/Bundle/Model/Product/Type.php
FOUND 1 ERROR AND 4 WARNINGS AFFECTING 5 LINES
398 | WARNING | [ ] Function's nesting level (6) exceeds 5;
| | consider refactoring the function
535 | ERROR | [x] Tags visual alignment must be consistent
1194 | WARNING | [ ] Empty FUNCTION statement detected
1212 | WARNING | [ ] array_merge(...) is used in a loop and is a
| | resources greedy construction.
1393 | WARNING | [ ] array_merge(...) is used in a loop and is a
| | resources greedy construction.
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
The following files incorrectly reuse fixtures:
/var/www/html/dev/tests/integration/testsuite/Magento/Bundle/_files/product_with_multiple_options_radio_select.php
/var/www/html/dev/tests/integration/testsuite/Magento/Bundle/_files/product_with_multiple_options_radio_select_rollback.php
Please use Magento\TestFramework\Workaround\Override\Fixture\Resolver::requireDataFixture
Failed asserting that 2 matches expected 0.
@@ -459,12 +461,12 @@ public function getOptionsIds($product) | |||
* Retrieve bundle option collection | |||
* | |||
* @param \Magento\Catalog\Model\Product $product | |||
* @return \Magento\Bundle\Model\ResourceModel\Option\Collection |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SVC is failing because of this, but I will approve it, it's a false positive
@@ -887,7 +894,7 @@ public function getSelectionsByIds($selectionIds, $product) | |||
* | |||
* @param array $optionIds | |||
* @param \Magento\Catalog\Model\Product $product | |||
* @return \Magento\Bundle\Model\ResourceModel\Option\Collection |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SVC is failing because of this, but I will approve it, it's a false positive
…erlatka/magento2 into 26110_bundle_product_options_fix
@magento run all tests |
@magento run Functional Tests B2B |
@magento run Functional Tests B2B |
@magento run Functional Tests EE |
Hi @michalderlatka, thank you for your contribution! |
Description (*)
Validates input for radio and select type options.
Related Pull Requests
Fixed Issues (if relevant)
Manual testing scenarios (*)
Follow instructions from related issue
Questions or comments
Contribution checklist (*)