Magento 2 : Use plugin / interceptor on abstract classMagento 2: Plugin before/around/after InteractionMagento 2 Plugin - ProductRepository getList overrideM2 Shipping Configuration class “interceptable” via around before or after mechanismMagento2: plugin around method not workingMagento 2 checkout Plugin, how to?Plugin for backend order create that sets attribute value on created orderCannot call abstract execute Magento 2Magento 2.1.3 Plugin problemRemove plugin (interceptor)Magento2 plugin/interceptor not working

How did Captain America manage to do this?

Does the sign matter for proportionality?

How exactly does Hawking radiation decrease the mass of black holes?

Why isn't the definition of absolute value applied when squaring a radical containing a variable?

A ​Note ​on ​N!

Shrinkwrap tetris shapes without scaling or diagonal shapes

What happened to Captain America in Endgame?

How to have a sharp product image?

Sci-fi novel series with instant travel between planets through gates. A river runs through the gates

How to make a pipeline wait for end-of-file or stop after an error?

Are Boeing 737-800’s grounded?

Why do Computer Science majors learn Calculus?

What do the phrase "Reeyan's seacrest" and the word "fraggle" mean in a sketch?

Binary Numbers Magic Trick

How to verbalise code in Mathematica?

Will a top journal at least read my introduction?

What language was spoken in East Asia before Proto-Turkic?

Realistic Necromancy?

How would one muzzle a full grown polar bear in the 13th century?

Controversial area of mathematics

Will tsunami waves travel forever if there was no land?

Critique of timeline aesthetic

Does this extra sentence in the description of the warlock's Eyes of the Rune Keeper eldritch invocation appear in any official reference?

Why was the Spitfire's elliptical wing almost uncopied by other aircraft of World War 2?



Magento 2 : Use plugin / interceptor on abstract class


Magento 2: Plugin before/around/after InteractionMagento 2 Plugin - ProductRepository getList overrideM2 Shipping Configuration class “interceptable” via around before or after mechanismMagento2: plugin around method not workingMagento 2 checkout Plugin, how to?Plugin for backend order create that sets attribute value on created orderCannot call abstract execute Magento 2Magento 2.1.3 Plugin problemRemove plugin (interceptor)Magento2 plugin/interceptor not working






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








2















I am trying to create a plugin that fires after MagentoSalesControllerAdminhtmlShipmentAbstractShipmentPrintAction::execute.

So I have my plugin setup in di.xml and an afterExecute() method, but it doesn't seem to get fired.

Now I know there are some limitations for plugins, but I can't read anything about abstract classes.

Can plugins / interceptors be used on abstract classes?










share|improve this question
















bumped to the homepage by Community 1 min ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.





















    2















    I am trying to create a plugin that fires after MagentoSalesControllerAdminhtmlShipmentAbstractShipmentPrintAction::execute.

    So I have my plugin setup in di.xml and an afterExecute() method, but it doesn't seem to get fired.

    Now I know there are some limitations for plugins, but I can't read anything about abstract classes.

    Can plugins / interceptors be used on abstract classes?










    share|improve this question
















    bumped to the homepage by Community 1 min ago


    This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.

















      2












      2








      2


      0






      I am trying to create a plugin that fires after MagentoSalesControllerAdminhtmlShipmentAbstractShipmentPrintAction::execute.

      So I have my plugin setup in di.xml and an afterExecute() method, but it doesn't seem to get fired.

      Now I know there are some limitations for plugins, but I can't read anything about abstract classes.

      Can plugins / interceptors be used on abstract classes?










      share|improve this question
















      I am trying to create a plugin that fires after MagentoSalesControllerAdminhtmlShipmentAbstractShipmentPrintAction::execute.

      So I have my plugin setup in di.xml and an afterExecute() method, but it doesn't seem to get fired.

      Now I know there are some limitations for plugins, but I can't read anything about abstract classes.

      Can plugins / interceptors be used on abstract classes?







      magento2 plugin interceptor






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 8 '16 at 14:46









      Marius

      168k28324694




      168k28324694










      asked Nov 8 '16 at 14:34









      Giel BerkersGiel Berkers

      7,20924383




      7,20924383





      bumped to the homepage by Community 1 min ago


      This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







      bumped to the homepage by Community 1 min ago


      This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.






















          1 Answer
          1






          active

          oldest

          votes


















          0














          Not 100% sure about this, but I think the plugins work for classes that get instantiated.

          The object manager instantiates the myclassInterceptor instead of myclass when there are plugins for that class.

          Since the abstract classes never get instantiated you won't have an Interceptor class generated that should call the plugins.

          But...

          I assume there is a class that extends MagentoSalesControllerAdminhtmlShipmentAbstractShipmentPrintAction and that one is actually instantiated and used.

          You can try to create the plugin for that class.

          Even if that class does not contain the execute method, it is still available (via parent class) so this means you should be able to add a plugin to it.






          share|improve this answer























          • Thanks for the tip. I moved my intercepter one level 'lower' but it's not yet getting picked up. It picks my plugin, but as soon as magento/framework/Interception/Interceptor.php::146 is executed (which is the call to the original method $result = parent::$method(...array_values($arguments));), the headers already get sent and the PDF is sent. Effectively ignoring my LISTENER_AFTER.

            – Giel Berkers
            Nov 8 '16 at 16:02











          • maybe you should try an around plugin and call the original method inside your plugin.

            – Marius
            Nov 8 '16 at 16:05











          • Already tried around. Before the callable the code gets executed, but as soon as I place it after the callable it doesn't work. I'm trying to fetch the result of the fileFactory. Could it be that it outputs the header and exits the script? Since I can't find I way to execute code after the PDF generating, I'm now executing it on before (which works) but it feels wrong since I only want to execute the code if I'm sure the PDF generation works.

            – Giel Berkers
            Nov 8 '16 at 16:09











          • Got it! Turns out that MagentoFrameworkAppResponseHttpFileFactory::create() is checking if $content !== null and if it's not it indeed starts sending headers and (as I suggested) is doing an exit(0), practically making it impossible for plugins to hook into after for this method. I think I'm going to report this as an issue...

            – Giel Berkers
            Nov 8 '16 at 16:12











          • Filed: github.com/magento/magento2/issues/7356

            – Giel Berkers
            Nov 8 '16 at 16:19











          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',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          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%2f144745%2fmagento-2-use-plugin-interceptor-on-abstract-class%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          Not 100% sure about this, but I think the plugins work for classes that get instantiated.

          The object manager instantiates the myclassInterceptor instead of myclass when there are plugins for that class.

          Since the abstract classes never get instantiated you won't have an Interceptor class generated that should call the plugins.

          But...

          I assume there is a class that extends MagentoSalesControllerAdminhtmlShipmentAbstractShipmentPrintAction and that one is actually instantiated and used.

          You can try to create the plugin for that class.

          Even if that class does not contain the execute method, it is still available (via parent class) so this means you should be able to add a plugin to it.






          share|improve this answer























          • Thanks for the tip. I moved my intercepter one level 'lower' but it's not yet getting picked up. It picks my plugin, but as soon as magento/framework/Interception/Interceptor.php::146 is executed (which is the call to the original method $result = parent::$method(...array_values($arguments));), the headers already get sent and the PDF is sent. Effectively ignoring my LISTENER_AFTER.

            – Giel Berkers
            Nov 8 '16 at 16:02











          • maybe you should try an around plugin and call the original method inside your plugin.

            – Marius
            Nov 8 '16 at 16:05











          • Already tried around. Before the callable the code gets executed, but as soon as I place it after the callable it doesn't work. I'm trying to fetch the result of the fileFactory. Could it be that it outputs the header and exits the script? Since I can't find I way to execute code after the PDF generating, I'm now executing it on before (which works) but it feels wrong since I only want to execute the code if I'm sure the PDF generation works.

            – Giel Berkers
            Nov 8 '16 at 16:09











          • Got it! Turns out that MagentoFrameworkAppResponseHttpFileFactory::create() is checking if $content !== null and if it's not it indeed starts sending headers and (as I suggested) is doing an exit(0), practically making it impossible for plugins to hook into after for this method. I think I'm going to report this as an issue...

            – Giel Berkers
            Nov 8 '16 at 16:12











          • Filed: github.com/magento/magento2/issues/7356

            – Giel Berkers
            Nov 8 '16 at 16:19















          0














          Not 100% sure about this, but I think the plugins work for classes that get instantiated.

          The object manager instantiates the myclassInterceptor instead of myclass when there are plugins for that class.

          Since the abstract classes never get instantiated you won't have an Interceptor class generated that should call the plugins.

          But...

          I assume there is a class that extends MagentoSalesControllerAdminhtmlShipmentAbstractShipmentPrintAction and that one is actually instantiated and used.

          You can try to create the plugin for that class.

          Even if that class does not contain the execute method, it is still available (via parent class) so this means you should be able to add a plugin to it.






          share|improve this answer























          • Thanks for the tip. I moved my intercepter one level 'lower' but it's not yet getting picked up. It picks my plugin, but as soon as magento/framework/Interception/Interceptor.php::146 is executed (which is the call to the original method $result = parent::$method(...array_values($arguments));), the headers already get sent and the PDF is sent. Effectively ignoring my LISTENER_AFTER.

            – Giel Berkers
            Nov 8 '16 at 16:02











          • maybe you should try an around plugin and call the original method inside your plugin.

            – Marius
            Nov 8 '16 at 16:05











          • Already tried around. Before the callable the code gets executed, but as soon as I place it after the callable it doesn't work. I'm trying to fetch the result of the fileFactory. Could it be that it outputs the header and exits the script? Since I can't find I way to execute code after the PDF generating, I'm now executing it on before (which works) but it feels wrong since I only want to execute the code if I'm sure the PDF generation works.

            – Giel Berkers
            Nov 8 '16 at 16:09











          • Got it! Turns out that MagentoFrameworkAppResponseHttpFileFactory::create() is checking if $content !== null and if it's not it indeed starts sending headers and (as I suggested) is doing an exit(0), practically making it impossible for plugins to hook into after for this method. I think I'm going to report this as an issue...

            – Giel Berkers
            Nov 8 '16 at 16:12











          • Filed: github.com/magento/magento2/issues/7356

            – Giel Berkers
            Nov 8 '16 at 16:19













          0












          0








          0







          Not 100% sure about this, but I think the plugins work for classes that get instantiated.

          The object manager instantiates the myclassInterceptor instead of myclass when there are plugins for that class.

          Since the abstract classes never get instantiated you won't have an Interceptor class generated that should call the plugins.

          But...

          I assume there is a class that extends MagentoSalesControllerAdminhtmlShipmentAbstractShipmentPrintAction and that one is actually instantiated and used.

          You can try to create the plugin for that class.

          Even if that class does not contain the execute method, it is still available (via parent class) so this means you should be able to add a plugin to it.






          share|improve this answer













          Not 100% sure about this, but I think the plugins work for classes that get instantiated.

          The object manager instantiates the myclassInterceptor instead of myclass when there are plugins for that class.

          Since the abstract classes never get instantiated you won't have an Interceptor class generated that should call the plugins.

          But...

          I assume there is a class that extends MagentoSalesControllerAdminhtmlShipmentAbstractShipmentPrintAction and that one is actually instantiated and used.

          You can try to create the plugin for that class.

          Even if that class does not contain the execute method, it is still available (via parent class) so this means you should be able to add a plugin to it.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 8 '16 at 14:45









          MariusMarius

          168k28324694




          168k28324694












          • Thanks for the tip. I moved my intercepter one level 'lower' but it's not yet getting picked up. It picks my plugin, but as soon as magento/framework/Interception/Interceptor.php::146 is executed (which is the call to the original method $result = parent::$method(...array_values($arguments));), the headers already get sent and the PDF is sent. Effectively ignoring my LISTENER_AFTER.

            – Giel Berkers
            Nov 8 '16 at 16:02











          • maybe you should try an around plugin and call the original method inside your plugin.

            – Marius
            Nov 8 '16 at 16:05











          • Already tried around. Before the callable the code gets executed, but as soon as I place it after the callable it doesn't work. I'm trying to fetch the result of the fileFactory. Could it be that it outputs the header and exits the script? Since I can't find I way to execute code after the PDF generating, I'm now executing it on before (which works) but it feels wrong since I only want to execute the code if I'm sure the PDF generation works.

            – Giel Berkers
            Nov 8 '16 at 16:09











          • Got it! Turns out that MagentoFrameworkAppResponseHttpFileFactory::create() is checking if $content !== null and if it's not it indeed starts sending headers and (as I suggested) is doing an exit(0), practically making it impossible for plugins to hook into after for this method. I think I'm going to report this as an issue...

            – Giel Berkers
            Nov 8 '16 at 16:12











          • Filed: github.com/magento/magento2/issues/7356

            – Giel Berkers
            Nov 8 '16 at 16:19

















          • Thanks for the tip. I moved my intercepter one level 'lower' but it's not yet getting picked up. It picks my plugin, but as soon as magento/framework/Interception/Interceptor.php::146 is executed (which is the call to the original method $result = parent::$method(...array_values($arguments));), the headers already get sent and the PDF is sent. Effectively ignoring my LISTENER_AFTER.

            – Giel Berkers
            Nov 8 '16 at 16:02











          • maybe you should try an around plugin and call the original method inside your plugin.

            – Marius
            Nov 8 '16 at 16:05











          • Already tried around. Before the callable the code gets executed, but as soon as I place it after the callable it doesn't work. I'm trying to fetch the result of the fileFactory. Could it be that it outputs the header and exits the script? Since I can't find I way to execute code after the PDF generating, I'm now executing it on before (which works) but it feels wrong since I only want to execute the code if I'm sure the PDF generation works.

            – Giel Berkers
            Nov 8 '16 at 16:09











          • Got it! Turns out that MagentoFrameworkAppResponseHttpFileFactory::create() is checking if $content !== null and if it's not it indeed starts sending headers and (as I suggested) is doing an exit(0), practically making it impossible for plugins to hook into after for this method. I think I'm going to report this as an issue...

            – Giel Berkers
            Nov 8 '16 at 16:12











          • Filed: github.com/magento/magento2/issues/7356

            – Giel Berkers
            Nov 8 '16 at 16:19
















          Thanks for the tip. I moved my intercepter one level 'lower' but it's not yet getting picked up. It picks my plugin, but as soon as magento/framework/Interception/Interceptor.php::146 is executed (which is the call to the original method $result = parent::$method(...array_values($arguments));), the headers already get sent and the PDF is sent. Effectively ignoring my LISTENER_AFTER.

          – Giel Berkers
          Nov 8 '16 at 16:02





          Thanks for the tip. I moved my intercepter one level 'lower' but it's not yet getting picked up. It picks my plugin, but as soon as magento/framework/Interception/Interceptor.php::146 is executed (which is the call to the original method $result = parent::$method(...array_values($arguments));), the headers already get sent and the PDF is sent. Effectively ignoring my LISTENER_AFTER.

          – Giel Berkers
          Nov 8 '16 at 16:02













          maybe you should try an around plugin and call the original method inside your plugin.

          – Marius
          Nov 8 '16 at 16:05





          maybe you should try an around plugin and call the original method inside your plugin.

          – Marius
          Nov 8 '16 at 16:05













          Already tried around. Before the callable the code gets executed, but as soon as I place it after the callable it doesn't work. I'm trying to fetch the result of the fileFactory. Could it be that it outputs the header and exits the script? Since I can't find I way to execute code after the PDF generating, I'm now executing it on before (which works) but it feels wrong since I only want to execute the code if I'm sure the PDF generation works.

          – Giel Berkers
          Nov 8 '16 at 16:09





          Already tried around. Before the callable the code gets executed, but as soon as I place it after the callable it doesn't work. I'm trying to fetch the result of the fileFactory. Could it be that it outputs the header and exits the script? Since I can't find I way to execute code after the PDF generating, I'm now executing it on before (which works) but it feels wrong since I only want to execute the code if I'm sure the PDF generation works.

          – Giel Berkers
          Nov 8 '16 at 16:09













          Got it! Turns out that MagentoFrameworkAppResponseHttpFileFactory::create() is checking if $content !== null and if it's not it indeed starts sending headers and (as I suggested) is doing an exit(0), practically making it impossible for plugins to hook into after for this method. I think I'm going to report this as an issue...

          – Giel Berkers
          Nov 8 '16 at 16:12





          Got it! Turns out that MagentoFrameworkAppResponseHttpFileFactory::create() is checking if $content !== null and if it's not it indeed starts sending headers and (as I suggested) is doing an exit(0), practically making it impossible for plugins to hook into after for this method. I think I'm going to report this as an issue...

          – Giel Berkers
          Nov 8 '16 at 16:12













          Filed: github.com/magento/magento2/issues/7356

          – Giel Berkers
          Nov 8 '16 at 16:19





          Filed: github.com/magento/magento2/issues/7356

          – Giel Berkers
          Nov 8 '16 at 16:19

















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Magento Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f144745%2fmagento-2-use-plugin-interceptor-on-abstract-class%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Disable / Remove link to Product Items in Cart Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?How can I limit products that can be bought / added to cart?Remove item from cartHide “Add to Cart” button if specific products are already in cart“Prettifying” the custom options in cart pageCreate link in cart sidebar to view all added items After limit reachedLink products together in checkout/cartHow to Get product from cart and add it againHide action-edit on cart page if simple productRemoving Cart items - ObserverRemove wishlist items when added to cart

          Helsingin valtaus Sisällysluettelo Taustaa | Yleistä sotatoimista | Osapuolet | Taistelut Helsingin ympäristössä | Punaisten antautumissuunnitelma | Taistelujen kulku Helsingissä | Valtauksen jälkeen | Tappiot | Muistaminen | Kirjallisuutta | Lähteet | Aiheesta muualla | NavigointivalikkoTeoksen verkkoversioTeoksen verkkoversioGoogle BooksSisällissota Helsingissä päättyi tasan 95 vuotta sittenSaksalaisten ylivoima jyräsi punaisen HelsinginSuomalaiset kuvaavat sotien jälkiä kaupungeissa – katso kuvat ja tarinat tutuilta kulmiltaHelsingin valtaus 90 vuotta sittenSaksalaiset valtasivat HelsinginHyökkäys HelsinkiinHelsingin valtaus 12.–13.4. 1918Saksalaiset käyttivät ihmiskilpiä Helsingin valtauksessa 1918Teoksen verkkoversioTeoksen verkkoversioSaksalaiset hyökkäävät Etelä-SuomeenTaistelut LeppävaarassaSotilaat ja taistelutLeppävaara 1918 huhtikuussa. KapinatarinaHelsingin taistelut 1918Saksalaisten voitonparaati HelsingissäHelsingin valtausta juhlittiinSaksalaisten Helsinki vuonna 1918Helsingin taistelussa kaatuneet valkokaartilaisetHelsinkiin haudatut taisteluissa kaatuneet punaiset12.4.1918 Helsingin valtauksessa saksalaiset apujoukot vapauttavat kaupunginVapaussodan muistomerkkejä Helsingissä ja pääkaupunkiseudullaCrescendo / Vuoden 1918 Kansalaissodan uhrien muistomerkkim

          Adjektiivitarina Tarinan tekeminen | Esimerkki: ennen | Esimerkki: jälkeen | Navigointivalikko