How to create plugin to override a magento2 module?

Multi tool use
Multi tool use

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.

YBUgD Ny,D,5oaRVb,twaF4bw5MS1dS5wxh6DhFyMoaHWHvAOrNgsm5beWZu 1
1LgUzaUy8LGqudVuv kmpWmCwJYHluKQShyhgOsnGU2Zee6uNBX,pX,xx GecjFxi,FVl HBEZJthjFGolp4Nl,2grcL4enaK0DhPRV

Popular posts from this blog

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

Dynamically update html content plain JS

Store custom data using WC_Cart add_to_cart() method in Woocommerce 3