-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Magento2 removed code pool . So what component is used to substituted the customization way? #450
Comments
The main reason of removing of the class rewrites and code pool is conflict of modules and version updates. But if you think that it real need for you then you can use autoloading to load your classes instead of magento. Just add to index.php code like:
|
Thanks for your answer. Looks Plugins is what I want. But I still got some errors. |
I just tried below the calling: The plugin feature is not available for:
Am I sinking into the limitation of Plugin?. Is there perfect solution for it? |
I found the line |
@guoguolong |
thanks @sshymko . Is below the solution for base calsses extending/overrite possible?
Then we simply declare the rewrite in di.xml as below:
Then run any magento page, at this time the compiler recompile out all derived calsses of \AbstractAddress into var/generation folder.
When call these derived classes, php loader load them in var/generation first , load the same classes in app/code if not found in var/generation |
@guoguolong Sorry for the delay in response. DI PreferencesDescendant classes are not going to be affected by the DI preference directive for the abstract class they inherit. Directory PluginsGood news, the mechanism of plugins has been significantly enhanced recently. It no longer has the limitations, described above: inability to intercept internal calls, lack of access to the pluginized object, etc. It's recommended to use plugins for cross-cutting customization, rather than class rewrites. |
@guoguolong, as we see, the response given by @sshymko is complete and correct. Please follow the provided recommendations. We are closing this issue. |
CABPI-397: Fix Failed Functional Tests CE Tests
As we've known, Magento2 removed 'code pool' . Is there a better way to substitute it in Magento2 ?
I try to use 'rewrite' to customize classes. But sometimes it doesn't work. For example,
It doesn't work when the class to be customized has one more derived classes and it's not called directly($objmgr->create('ClassNameToBeCustomized'))
See below the living sample. I Added a line to di.xml in my module's
The Magento\Customer\Model\Address\AbstractAddress class is a basic class which haven't been called directly. Means:
There are fews classes
Magento\Customer\Model\Address
Magento\Sales\Model\Order\Address
Magento\Sales\Model\Quote\Address
extend Magento\Customer\Model\Address\AbstractAddress.It's called when call above one of 3 classes. I found the rewrite doesn't work at all, Is there anybody can give some suggestions ?
The text was updated successfully, but these errors were encountered: