quote_item from
to
quote_item table.The problem is that the product is no longer found. So the sales rule condition is breaking the page.
For instance, if this line (68) would be set to $validated = true; //$cond->validate($item); https://github.com/magento/magento2/blob/8628eb8b346ea7adceca720f04f04d9f5474da7c/app/code/Magento/SalesRule/Model/Rule/Condition/Product/Found.php#L67-L70 we would then get this page

Note that this also leaves lots of data in the database. not only does it not clean the quote_item table properly but it does not remove the linked data from the quote_item_option table either.
This causes these tables to be very large for no reason. In my case more than 1.5M rows could be deleted.
This plugin does is responsible for cleaning the table but does a half job since the parent configurable product will not be removed from the quotes and hence the cause of this bug. In my opinion, this delete should be done by sku so that all the product get removed. In this case, an index would be required on the sku column.
A better fix for this would be to add a foreign key constraint on the quote_item table with the catalog_product_entity table and cascade on delete. That would completely remove the need for that plugin and all the code that it involves. I'm curious to see comments regarding this. I'm really asking myself why the decision was made to use a plugin in this case.
Also, some third party vendors bypass the plugins and events thrown by this method and hence leave an even bigger mess in the db. For instance, using a module such as RapidFlow to remove products will not trigger the plugins nor the event thrown by this method.
https://github.com/magento/magento2/blob/8628eb8b346ea7adceca720f04f04d9f5474da7c/app/code/Magento/Catalog/Model/ResourceModel/Product.php#L369-L377
One more reason why I believe this should be fixed with a database foreign key and probably an additional index on the sku column.
quote_item table.Hi @drew7721. Thank you for your report.
To help us process this issue please make sure that you provided the following information:
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:
@magento give me 2.4-develop instance - upcoming 2.4.x release
For more details, please, review the Magento Contributor Assistant documentation.
@drew7721 do you confirm that you were able to reproduce the issue on vanilla Magento instance following steps to reproduce?
Hi @drew7721. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:
Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.[x] 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.
[x] 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.
2.4-develop branch@magento give me 2.4-develop instance to deploy test instance on Magento infrastructure. 2.4-develop branch, please, add the label Reproduced on 2.4.x.Hi @shikhamis11. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:
Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.[ ] 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.
[ ] 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.
[ ] 4. Verify that the issue is reproducible on 2.4-develop branchDetails
- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
- If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
- If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and _stop verification process here_!
[ ] 5. Add label Issue: Confirmed once verification is complete.
[ ] 6. Make sure that automatic system confirms that report has been added to the backlog.
@shikhamis11 Thank you for verifying the issue.
Unfortunately, not enough information was provided to acknowledge ticket. Please consider adding the following:
"Reproduced on " label(s) to this ticket based on verification resultOnce all required information is added, please add label "Issue: Confirmed" again.
Thanks!
:white_check_mark: Confirmed by @shikhamis11
Thank you for verifying the issue. Based on the provided information internal tickets MC-31571 were created
Issue Available: @shikhamis11, _You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself._
Hi @drew7721. Thank you for working on this issue.
Looks like this issue is already verified and confirmed. But if you want to validate it one more time, please, go though the following instruction:
Component: XXXXX label(s) to the ticket, indicating the components it may be related to.[ ] 2. Verify that the issue is reproducible on 2.4-develop branchDetails
- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
- If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
- If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and _stop verification process here_!
[ ] 3. If the issue is not relevant or is not reproducible any more, feel free to close it.
After looking into this, it seem that the same issue was happening with the wishlist.
See first release note for 2.3.1
I assume this could be fixed in the same way. Looking for the commit that fixed that. For some reason there is no link in the release notes.
@drew7721: just a hint, if you look in the source code of the release notes, you'll find the ticket number: MAGETWO-95311. If you then search for commits in a clone of this git repo using something like: git log origin/2.4-develop --grep 'MAGETWO-95311', you'll find 2 commits:
Not sure if this will be helpful here, but now you learned how to find fixes from the release notes in the git repository 馃檪
Great hint @hostep ! That will be very handy! Thanks!
@magento I鈥檓 working on it
@magento I am working on this
Most helpful comment
@drew7721: just a hint, if you look in the source code of the release notes, you'll find the ticket number:
MAGETWO-95311. If you then search for commits in a clone of this git repo using something like:git log origin/2.4-develop --grep 'MAGETWO-95311', you'll find 2 commits:Not sure if this will be helpful here, but now you learned how to find fixes from the release notes in the git repository 馃檪