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
TierPriceManagement: add() fails randomly because of invalid argument supplied for foreach() #30908
Comments
Hi @HenriNijborg. Thank you for your report.
Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:
For more details, please, review the Magento Contributor Assistant documentation. Please, add a comment to assign the issue:
🕙 You can find the schedule on the Magento Community Calendar page. 📞 The triage of issues 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 I am working on this |
@engcom-Alfa Should I proceed with the suggested solution by @HenriNijborg ? |
I think there is a second line that needs fixing: should be retrieving the products without using the cache as it will be used to compare the new rules to the existing ones. If the cache isn't valid then my suggested fix will cause no error and it will proceed and overide possibly tier prices which aren't in the cache but are in the db.
I'm not a Magento 2 developer so I'm not sure which one it should be. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 14 days if no further activity occurs. Is this issue still relevant? If so, what is blocking it? Is there anything you can do to help move it forward? Thank you for your contributions! |
Yes, this issue is still relevant. Pull Request author @chiranjeevi-cj asked for help from @magento-engcom-team in related pull request #30941 |
What is the status of this issue? We would also like to have it fixed. |
@magento-engcom-team @chiranjeevi-cj |
Hi @HenriNijborg, Thank you for reporting and collaboration. Verified the issue on Magento 2.4-develop instance and the issue is not reproducible.Kindly refer the screenshots. 1.Added a tier price programmaticaly using the TierPriceManagement class. The issue is no more reproducible.it is already fixed in 2.4-develop. Thanks. |
File: app/code/Magento/Catalog/Model/Product/TierPriceManagement.php
Function: add()
Error
Invalid argument supplied for foreach()
on lineforeach ($tierPrices as &$item)
The behaviour is random. Strongly related to issue #24410 and bug fix 114ac4b
Preconditions (*)
Steps to reproduce (*)
foreach ($tierPrices as &$item)
randomly throwsInvalid argument supplied for foreach()
Expected result (*)
Actual result (*)
$tierPrices
isn't checked for beingnull
causing the error.Suspicions
I think the result of a cached product has
tier_price: null
and the non cached product istier_price: []
as the behaviour is randomly and caching might be not for all products and not always valid anymore.Suggested fix
Please provide Severity assessment for the Issue as Reporter. This information will help during Confirmation and Issue triage processes.
The text was updated successfully, but these errors were encountered: