-
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
Don't use $rate as an object (it is an array) #30052
Conversation
`$rate` is an array and it does not contain `id` item. We can use rate's `code` item as part of `id` for HTML nodes.
Hi @flancer64. 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 |
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.
Hi @flancer64
Thanks for your contribution
Could you, please take a look at my comments?
<?php | ||
$rateCode = strtolower($rate['code']); | ||
$rateId = str_replace(' ', '-', $rateCode); | ||
?> |
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.
Please, don't hold logic in the template. Can you put this to view Model?
$rateCode = strtolower($rate['code']); | ||
$rateId = str_replace(' ', '-', $rateCode); | ||
?> | ||
<tr id="rate-<?= /* @noEscape */ $rateId ?>" |
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.
Why should we keep $rateId as the name of the variable?
Hello, @Stepa4man . Sorry, I cannot "move logic from template to view Model". I don't know what a right logic should be here. I've just fixed the bug. Someone wrote this:
for array I'm sorry again, but I have no answer to question "Why should we keep $rateId as the name of the variable?" :( You shouldn't. It just my own choice. Please, feel free to reject this pull request if it doesn't match your rules. |
Hi, @flancer64, are you able to continue with this pull request? Also could you please cover your code changes with an MFTF test? You can use the following Magento Functional Testing Framework Guide to get acquainted with it. Thank you! |
@engcom-Golf , I cannot use I agree that the better way is to use |
Maybe we can use |
@flancer64, please look at \Magento\Tax\Model\ResourceModel\Calculation::getCalculationProcess method. There should be an ability to add rate id to the output array. |
Thanks, @engcom-Golf . This is the way. This SQL is composed to select rates data in SELECT
`main_table` .*
FROM
`sales_order_tax` AS `main_table`
WHERE
(main_table.order_id = 1234)
ORDER BY
`process` ASC so, we can use |
@magento run all tests |
Hi, @flancer64, thank you for your changes, but as we can see from failed tests, this approach is not acceptable. I have made some investigations and found that rates are taken not only from the database. So tax_id can be not present in rates array. Suppose we can use 'for each' loop index, as you have proposed before. |
@engcom-Golf , done. |
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.
@flancer64 sorry for delay
Due to Magento Definition of Done all code must be covered by tests.
Could you add automation test that cover your changes?
@engcom-Delta , I'm sorry, I couldn't. |
Hi @flancer64, I just analyzed another solution that we have - seems like array index solution potentially might cause ID duplication, as in some other place on the page might be same id I'm closing this PR as we just have better solution for the same issue in #30516. Thank you so much for your contribution! |
Hi @flancer64, thank you for your contribution! |
Description (*)
$rate
is an array and it does not containid
item. We can use rate'scode
item as part ofid
for HTML nodes.Contribution checklist (*)