Saving a value without triggering aftersave()












0















I'm not going in detail about what i'm exactly saving because this question is regards all the possible thing you can save with the ->save() function in each repository.



Anyways , when importing data from an API i use the save() method to store the data that i retrieved. Now it seems that that save() will trigger my plugin AfterSave().



Which makes sense right?



But now is the question. The AfterSave() is ment for when a customer or an admin saves an order/product/customer/... and not for when this is triggered over an autosync (cron job).



Is there somewhere where i can put a filter to determine when to use aftersave and when not?










share|improve this question





























    0















    I'm not going in detail about what i'm exactly saving because this question is regards all the possible thing you can save with the ->save() function in each repository.



    Anyways , when importing data from an API i use the save() method to store the data that i retrieved. Now it seems that that save() will trigger my plugin AfterSave().



    Which makes sense right?



    But now is the question. The AfterSave() is ment for when a customer or an admin saves an order/product/customer/... and not for when this is triggered over an autosync (cron job).



    Is there somewhere where i can put a filter to determine when to use aftersave and when not?










    share|improve this question



























      0












      0








      0








      I'm not going in detail about what i'm exactly saving because this question is regards all the possible thing you can save with the ->save() function in each repository.



      Anyways , when importing data from an API i use the save() method to store the data that i retrieved. Now it seems that that save() will trigger my plugin AfterSave().



      Which makes sense right?



      But now is the question. The AfterSave() is ment for when a customer or an admin saves an order/product/customer/... and not for when this is triggered over an autosync (cron job).



      Is there somewhere where i can put a filter to determine when to use aftersave and when not?










      share|improve this question
















      I'm not going in detail about what i'm exactly saving because this question is regards all the possible thing you can save with the ->save() function in each repository.



      Anyways , when importing data from an API i use the save() method to store the data that i retrieved. Now it seems that that save() will trigger my plugin AfterSave().



      Which makes sense right?



      But now is the question. The AfterSave() is ment for when a customer or an admin saves an order/product/customer/... and not for when this is triggered over an autosync (cron job).



      Is there somewhere where i can put a filter to determine when to use aftersave and when not?







      magento2 api save






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 24 mins ago









      Teja Bhagavan Kollepara

      2,94841847




      2,94841847










      asked Sep 25 '17 at 9:07









      SwAt.BeSwAt.Be

      1,375624




      1,375624






















          1 Answer
          1






          active

          oldest

          votes


















          2














          This is where the "area" plays a vital role. You can achieve this by carefully adding your plugin in an appropriate area.



          Magento 2 has different areas. For example: frontend, admin, web_api etc. If you want to use your plugin only in frontend, then place your plugin in frontend area and thus you can limit the functionality.



          ie placing your di.xml




          appcodeNamespaceModuleetcdi.xml -- applies everywhere
          appcodeNamespaceModuleetcfrontenddi.xml -- applies only for
          frotend appcodeNamespaceModuleetcadminhtmldi.xml -- applies only
          for backend side appcodeNamespaceModuleetcweb_apidi.xml --
          applies only for apis




          will have different effects. So always keep "area" scope while you are codding. This is a powerful feature to avoid unnecessary config loadings and hence vital for performance.






          share|improve this answer


























          • So if i'm right i want to add that to the admin area and the frontend area. And what happends over ssh won't trigger the plugin?

            – SwAt.Be
            Sep 25 '17 at 9:16













          • And by areas you mean put my di.xml in the etc/frontend/ || adminhtml/ folder instead of the etc/ folder.

            – SwAt.Be
            Sep 25 '17 at 9:18











          • Yes, exactly. For custom commands I believe we can set an area as per our need. I am not sure whether there is an "area" for native commands.

            – Rajeev K Tomy
            Sep 25 '17 at 9:23











          • I tried this and it does indeed work great! Thanks , you just reduced my api load by 80% i believe. Big vote up!

            – SwAt.Be
            Sep 25 '17 at 9:24











          • Please see my edit too.

            – Rajeev K Tomy
            Sep 25 '17 at 9:28











          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%2f194564%2fsaving-a-value-without-triggering-aftersave%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









          2














          This is where the "area" plays a vital role. You can achieve this by carefully adding your plugin in an appropriate area.



          Magento 2 has different areas. For example: frontend, admin, web_api etc. If you want to use your plugin only in frontend, then place your plugin in frontend area and thus you can limit the functionality.



          ie placing your di.xml




          appcodeNamespaceModuleetcdi.xml -- applies everywhere
          appcodeNamespaceModuleetcfrontenddi.xml -- applies only for
          frotend appcodeNamespaceModuleetcadminhtmldi.xml -- applies only
          for backend side appcodeNamespaceModuleetcweb_apidi.xml --
          applies only for apis




          will have different effects. So always keep "area" scope while you are codding. This is a powerful feature to avoid unnecessary config loadings and hence vital for performance.






          share|improve this answer


























          • So if i'm right i want to add that to the admin area and the frontend area. And what happends over ssh won't trigger the plugin?

            – SwAt.Be
            Sep 25 '17 at 9:16













          • And by areas you mean put my di.xml in the etc/frontend/ || adminhtml/ folder instead of the etc/ folder.

            – SwAt.Be
            Sep 25 '17 at 9:18











          • Yes, exactly. For custom commands I believe we can set an area as per our need. I am not sure whether there is an "area" for native commands.

            – Rajeev K Tomy
            Sep 25 '17 at 9:23











          • I tried this and it does indeed work great! Thanks , you just reduced my api load by 80% i believe. Big vote up!

            – SwAt.Be
            Sep 25 '17 at 9:24











          • Please see my edit too.

            – Rajeev K Tomy
            Sep 25 '17 at 9:28
















          2














          This is where the "area" plays a vital role. You can achieve this by carefully adding your plugin in an appropriate area.



          Magento 2 has different areas. For example: frontend, admin, web_api etc. If you want to use your plugin only in frontend, then place your plugin in frontend area and thus you can limit the functionality.



          ie placing your di.xml




          appcodeNamespaceModuleetcdi.xml -- applies everywhere
          appcodeNamespaceModuleetcfrontenddi.xml -- applies only for
          frotend appcodeNamespaceModuleetcadminhtmldi.xml -- applies only
          for backend side appcodeNamespaceModuleetcweb_apidi.xml --
          applies only for apis




          will have different effects. So always keep "area" scope while you are codding. This is a powerful feature to avoid unnecessary config loadings and hence vital for performance.






          share|improve this answer


























          • So if i'm right i want to add that to the admin area and the frontend area. And what happends over ssh won't trigger the plugin?

            – SwAt.Be
            Sep 25 '17 at 9:16













          • And by areas you mean put my di.xml in the etc/frontend/ || adminhtml/ folder instead of the etc/ folder.

            – SwAt.Be
            Sep 25 '17 at 9:18











          • Yes, exactly. For custom commands I believe we can set an area as per our need. I am not sure whether there is an "area" for native commands.

            – Rajeev K Tomy
            Sep 25 '17 at 9:23











          • I tried this and it does indeed work great! Thanks , you just reduced my api load by 80% i believe. Big vote up!

            – SwAt.Be
            Sep 25 '17 at 9:24











          • Please see my edit too.

            – Rajeev K Tomy
            Sep 25 '17 at 9:28














          2












          2








          2







          This is where the "area" plays a vital role. You can achieve this by carefully adding your plugin in an appropriate area.



          Magento 2 has different areas. For example: frontend, admin, web_api etc. If you want to use your plugin only in frontend, then place your plugin in frontend area and thus you can limit the functionality.



          ie placing your di.xml




          appcodeNamespaceModuleetcdi.xml -- applies everywhere
          appcodeNamespaceModuleetcfrontenddi.xml -- applies only for
          frotend appcodeNamespaceModuleetcadminhtmldi.xml -- applies only
          for backend side appcodeNamespaceModuleetcweb_apidi.xml --
          applies only for apis




          will have different effects. So always keep "area" scope while you are codding. This is a powerful feature to avoid unnecessary config loadings and hence vital for performance.






          share|improve this answer















          This is where the "area" plays a vital role. You can achieve this by carefully adding your plugin in an appropriate area.



          Magento 2 has different areas. For example: frontend, admin, web_api etc. If you want to use your plugin only in frontend, then place your plugin in frontend area and thus you can limit the functionality.



          ie placing your di.xml




          appcodeNamespaceModuleetcdi.xml -- applies everywhere
          appcodeNamespaceModuleetcfrontenddi.xml -- applies only for
          frotend appcodeNamespaceModuleetcadminhtmldi.xml -- applies only
          for backend side appcodeNamespaceModuleetcweb_apidi.xml --
          applies only for apis




          will have different effects. So always keep "area" scope while you are codding. This is a powerful feature to avoid unnecessary config loadings and hence vital for performance.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Dec 19 '17 at 7:52









          Goose84

          1,27911240




          1,27911240










          answered Sep 25 '17 at 9:14









          Rajeev K TomyRajeev K Tomy

          14.4k54585




          14.4k54585













          • So if i'm right i want to add that to the admin area and the frontend area. And what happends over ssh won't trigger the plugin?

            – SwAt.Be
            Sep 25 '17 at 9:16













          • And by areas you mean put my di.xml in the etc/frontend/ || adminhtml/ folder instead of the etc/ folder.

            – SwAt.Be
            Sep 25 '17 at 9:18











          • Yes, exactly. For custom commands I believe we can set an area as per our need. I am not sure whether there is an "area" for native commands.

            – Rajeev K Tomy
            Sep 25 '17 at 9:23











          • I tried this and it does indeed work great! Thanks , you just reduced my api load by 80% i believe. Big vote up!

            – SwAt.Be
            Sep 25 '17 at 9:24











          • Please see my edit too.

            – Rajeev K Tomy
            Sep 25 '17 at 9:28



















          • So if i'm right i want to add that to the admin area and the frontend area. And what happends over ssh won't trigger the plugin?

            – SwAt.Be
            Sep 25 '17 at 9:16













          • And by areas you mean put my di.xml in the etc/frontend/ || adminhtml/ folder instead of the etc/ folder.

            – SwAt.Be
            Sep 25 '17 at 9:18











          • Yes, exactly. For custom commands I believe we can set an area as per our need. I am not sure whether there is an "area" for native commands.

            – Rajeev K Tomy
            Sep 25 '17 at 9:23











          • I tried this and it does indeed work great! Thanks , you just reduced my api load by 80% i believe. Big vote up!

            – SwAt.Be
            Sep 25 '17 at 9:24











          • Please see my edit too.

            – Rajeev K Tomy
            Sep 25 '17 at 9:28

















          So if i'm right i want to add that to the admin area and the frontend area. And what happends over ssh won't trigger the plugin?

          – SwAt.Be
          Sep 25 '17 at 9:16







          So if i'm right i want to add that to the admin area and the frontend area. And what happends over ssh won't trigger the plugin?

          – SwAt.Be
          Sep 25 '17 at 9:16















          And by areas you mean put my di.xml in the etc/frontend/ || adminhtml/ folder instead of the etc/ folder.

          – SwAt.Be
          Sep 25 '17 at 9:18





          And by areas you mean put my di.xml in the etc/frontend/ || adminhtml/ folder instead of the etc/ folder.

          – SwAt.Be
          Sep 25 '17 at 9:18













          Yes, exactly. For custom commands I believe we can set an area as per our need. I am not sure whether there is an "area" for native commands.

          – Rajeev K Tomy
          Sep 25 '17 at 9:23





          Yes, exactly. For custom commands I believe we can set an area as per our need. I am not sure whether there is an "area" for native commands.

          – Rajeev K Tomy
          Sep 25 '17 at 9:23













          I tried this and it does indeed work great! Thanks , you just reduced my api load by 80% i believe. Big vote up!

          – SwAt.Be
          Sep 25 '17 at 9:24





          I tried this and it does indeed work great! Thanks , you just reduced my api load by 80% i believe. Big vote up!

          – SwAt.Be
          Sep 25 '17 at 9:24













          Please see my edit too.

          – Rajeev K Tomy
          Sep 25 '17 at 9:28





          Please see my edit too.

          – Rajeev K Tomy
          Sep 25 '17 at 9:28


















          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%2f194564%2fsaving-a-value-without-triggering-aftersave%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

          What other Star Trek series did the main TNG cast show up in?

          Berlina muro

          Berlina aerponto