-
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
Backward compatibility has been lost on Magento\Catalog\Model\ProductRepository class #38669
Comments
Hi @davidmolinacano. Thank you for your report.
Join Magento Community Engineering Slack and ask your questions in #github channel. |
Issue was caused by #37868, which actually fixed a bug by removing the dependency. Not sure if it will be easy to keep this fix and not break backwards compatibility. Just my 2 cents, others are free to give their own opinions though 🙂 |
Thank you very much for the explanation @hostep ! Unfortunately, if this fix cannot be reverted we would need a proper solution for our specific case, because we must keep BC in our module since most of our customers are still using versions lower than 2.4.7, but a few of them are currently using the 2.4.7 too. If someone has any proposal about this issue, I'll be glad to hear it (well, in this case to read it). |
So doofinder/doofinder-magento2@f9da4d2 is not fixing it? We did use a solution like this in the past to be compatible with various magento versions with constructors that don't take the same amount of arguments: #30684 (comment) |
Unfortunately it didn't work as expected. Even with this fix, the setup:di:compile was still complaining about this. But thank you very much for pointing it, just in case. |
Hi @engcom-Hotel. Thank you for working on this issue.
|
Hello @davidmolinacano, Thanks for the report and collaboration! By looking into the codebase we are confirming this issue. The changes are Backward incompatible. Thanks |
✅ Jira issue https://jira.corp.adobe.com/browse/AC-11874 is successfully created for this GitHub issue. |
✅ Confirmed by @engcom-Hotel. Thank you for verifying the issue. |
@davidmolinacano We can't just add back this parameter since it was already removed in 2.4.7. Just adding it back in 2.4.8 will cause backward incompatible change again. I think we should provide some workaround for this issue for you. I guess the correct fix would be adding some if statement and compare magento version.
Could you please provide some details which exception do you have? Also, would be great to get output from running a CLI command with the |
Of course, I'm pasting here the results of the command (Tested on Magento 2.4.7 and PHP 8.2):
Even forcing the if with false (just in case) it only takes into account the first statement and ignore the second one:
|
Backward compatibility has been lost in the Magento\Catalog\Model\ProductRepository class Check the issue page in the Magento repo for reference: magento/magento2#38669
@sofia-doofinder, sorry, no updates The workaround example you can see in #38669 (comment) |
@davidmolinacano @sofia-doofinder @hostep @ihor-sviziev The approach of checking the current Magento version and serving the appropriate arguments of the parent method is working as expected. I have reviewed the corresponding commit on the Doofinder repository and tested it in my own environment. During testing, I encountered the following error:
You may observe that the error message has changed. The issue was resolved by placing the I have submitted a pull request to the Doofinder repository to fix this issue. doofinder/doofinder-magento2#317 @davidmolinacano This is my first time hearing about the Doofinder search feature, and it looks great. Keep up the good work! |
Hello @TuVanDev I'm checking you PR but it didn't work, as @davidmolinacano said the if seems not work at all... I'm using your branch, and I'm using magento 2.4.3, when I run the comman
So it is saying that expect as required type So it looks like is trying to load the if statment instead of access by the else, becuase is the first statment where is ignored the The weired thing is that if I change the if to seems that the if is not workingn as expected because always tries to load the first statment.... |
@TuVanDev @sofia-doofinder Can you try removing constructor override and try something like this instead? |
thank you @ihor-sviziev I'm going to check |
…t in the Magento\Catalog\Model\ProductRepository class Check the issue page in the Magento repo for reference: magento/magento2#38669
…t in the Magento\Catalog\Model\ProductRepository class Check the issue page in the Magento repo for reference: magento/magento2#38669
Hi @sofia-doofinder , thanks for letting me know. I have reviewed the interception generation code and discovered that the
As a result, the I have another solution, which is to rebuild your |
…t in the Magento\Catalog\Model\ProductRepository class (#318) * Compatible with Magento 2.4.7, as backward compatibility has been lost in the Magento\Catalog\Model\ProductRepository class Check the issue page in the Magento repo for reference: magento/magento2#38669 * Update Model/ProductRepository.php Changed inventoryHelper to inventoryHelperFactory Co-authored-by: sofia-doofinder <92720455+sofia-doofinder@users.noreply.github.com> --------- Co-authored-by: David Molina Cano <128705267+davidmolinacano@users.noreply.github.com> Co-authored-by: sofia-doofinder <92720455+sofia-doofinder@users.noreply.github.com>
@TuVanDev thank you for your PR, we've try to upload to magento market but the code sniffer fails with the following reason: So we can't do on that way... any help please? |
@sofia-doofinder In this case, your team can go with the approach I suggested previously #38669 (comment)
Starting from Magento version 2.4.7, the class Magento\Catalog\Model\ProductRepository now includes the implementation of Magento\Framework\ObjectManager\ResetAfterRequestInterface.
To support both older Magento versions and Magento version 2.4.7+, you should avoid using this implementation. Therefore, your class should look like this:
|
Hello, Internal team has started to work on it Thanks |
Hi @davidmolinacano, Thanks for your reporting and collaboration. we have analysed the issue on the 2.4 develop and installed extension doofinder-magento2 for reproducing the issue. We have found that the issue is not reproducible. I have attached the screenshot for reference. Thanks. |
@engcom-Bravo this issue has been confirmed by @engcom-Hotel #38669 (comment). The doofinder-magento2 module has resolved this issue by implement a workaround as per my suggestion at #38669 (comment) If you want to reproduce the issue with that module, you can install version 0.13.13, which didn't apply the fix. |
I still stand by my point from my first comment, that we should just leave this be and don't attempt to fix this in core Magento. |
Hi @davidmolinacano, @hostep @TuVanDev Thanks for your contribution!! As per this #38669 (comment) We are closing this issue. Thanks. |
Summary
I've a module that have a ProductRepository class which extends from the core
Magento\Catalog\Model\ProductRepository
class. We were calling the parent::__construct passing theMagento\Catalog\Controller\Adminhtml\Product\Initialization\Helper
class which was required before Magento 2.4.7 as the 2nd parameter of the constructor, but now it has been removed and the second parameter must beMagento\Catalog\Api\Data\ProductSearchResultsInterfaceFactory
class instead, thus losing the backward compatibility.Examples
(Tested on Magento 2.4.3 after having removed the initialization helper from the parent::__construct)
Proposed solution
My proposal is to restore the
Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper
class as the second parameter. Although it's unused as you stated on the changelog, in my opinion it's required to guarantee the backward compatibility.This bug can be reproduced by installing our module (version 0.13.13) on a Magento 2.4.7 and then executing a
bin/magento setup:di:compile
Release note
Release Line: 2.4.7
Triage and priority
The text was updated successfully, but these errors were encountered: