I can not override a protected function using plugin. iS there any other way to override the same function?
-
you can use override like as controller model we did without plugin– Ansar HusainCommented Sep 24, 2018 at 4:33
-
Check this stack, it explains how you can override a protected function in the correct way stackoverflow.com/questions/44241663/…– KorbinCommented Sep 24, 2018 at 6:29
Add a comment
|
1 Answer
You can not override protected function using plugin.
Plugin Limitations:
Plugins cannot be used with any of the following:
Final methods
Final classes
Non-public methods
Static methods
__construct
Virtual types
Objects that are instantiated before Magento\Framework\Interception is bootstrapped
Objects that are not instantiated by the ObjectManager (e.g. by using new directly).
For More Details refer Magento Devdoc
https://devdocs.magento.com/guides/v2.0/extension-dev-guide/plugins.html
In your case, you can use Preference to override these classes which have protected mathod.