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





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;







up vote
2
down vote

favorite












I can not override a protected function using plugin. iS there any other way to override the same function?










share|improve this question





















  • you can use override like as controller model we did without plugin
    – Ansar Husain
    1 hour ago
















up vote
2
down vote

favorite












I can not override a protected function using plugin. iS there any other way to override the same function?










share|improve this question





















  • you can use override like as controller model we did without plugin
    – Ansar Husain
    1 hour ago












up vote
2
down vote

favorite









up vote
2
down vote

favorite











I can not override a protected function using plugin. iS there any other way to override the same function?










share|improve this question













I can not override a protected function using plugin. iS there any other way to override the same function?







magento2 plugin






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked 1 hour ago









Divya Muralidharan

3231316




3231316











  • you can use override like as controller model we did without plugin
    – Ansar Husain
    1 hour ago
















  • you can use override like as controller model we did without plugin
    – Ansar Husain
    1 hour ago















you can use override like as controller model we did without plugin
– Ansar Husain
1 hour ago




you can use override like as controller model we did without plugin
– Ansar Husain
1 hour ago










1 Answer
1






active

oldest

votes

















up vote
2
down vote













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.






share|improve this answer




















    Your Answer







    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "479"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: false,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













     

    draft saved


    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f243411%2fhow-to-create-plugin-to-override-a-magento2-module%23new-answer', 'question_page');

    );

    Post as a guest






























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    2
    down vote













    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.






    share|improve this answer
























      up vote
      2
      down vote













      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.






      share|improve this answer






















        up vote
        2
        down vote










        up vote
        2
        down vote









        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.






        share|improve this 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 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.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 1 hour ago









        akgola

        1,203413




        1,203413



























             

            draft saved


            draft discarded















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f243411%2fhow-to-create-plugin-to-override-a-magento2-module%23new-answer', 'question_page');

            );

            Post as a guest













































































            Comments

            Popular posts from this blog

            Long meetings (6-7 hours a day): Being “babysat” by supervisor

            What does second last employer means? [closed]

            One-line joke