How to create plugin to override a magento2 module?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



How to create plugin to override a magento2 module?



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 Husain
1 hour ago




1 Answer
1



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 MagentoFrameworkInterception 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.






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

How to determine optimal route across keyboard