Magento 2 Module Observer Sequence order and Sales Order EventWhat order the same event will fire if it is captured in several modules?Is there any specific order of invoking observer functions?Magento 2: Change Customer Group Once Order is Completed for ProductWhat Magento Event fires on 'Reorder'?Sales order observer event issueHow to create a event observer which trigger after a customer placed an orderMagento 2 Event sales_order_payment_pay not triggeringMagento 2: Get Payment Information in checkout_submit_all_after event observerMagento 2 - Sales Order Shipment Event/ObserverMagento 2 - Why does `sales_order_save_commit_after` not fire when user is not logged in?

Having to constantly redo everything because I don't know how to do it

What are the children of two Muggle-borns called?

How to count the number of bytes in a file, grouping the same bytes?

Apollo Mission Operations Control Room 2 display, what do these numbers indicate?

Why didn't Avengers simply jump 5 years back?

Smart contract transaction of 0 XTZ throwing error from TEZBOX

Why should I allow multiple IP addresses on a website for a single session?

Does Flashpoint ever indicate directly that it takes place in Toronto?

Where to connect the fuse and why?

English idiomatic equivalents of 能骗就骗 (if you can cheat, then cheat)

Could you fall off a planet if it was being accelerated by engines?

Is it OK to say "The situation is pregnant with a crisis"?

How does mmorpg store data?

What is this fluorinated organic substance?

Do electrons really perform instantaneous quantum leaps?

How does the 'five minute adventuring day' affect class balance?

Why was Pan Am Flight 103 flying over Lockerbie?

How do I debug a dependency package? If I have its source code

Odd PCB Layout for Voltage Regulator

How many transistors are there in a logic gate?

How useful would a hydroelectric power plant be in the post-apocalypse world?

Does "boire un jus" tend to mean "coffee" or "juice of fruit"?

Cat files in subfolders in order given by a list

iMac 2019: Can I mix the old modules with the new ones when upgrading RAM?



Magento 2 Module Observer Sequence order and Sales Order Event


What order the same event will fire if it is captured in several modules?Is there any specific order of invoking observer functions?Magento 2: Change Customer Group Once Order is Completed for ProductWhat Magento Event fires on 'Reorder'?Sales order observer event issueHow to create a event observer which trigger after a customer placed an orderMagento 2 Event sales_order_payment_pay not triggeringMagento 2: Get Payment Information in checkout_submit_all_after event observerMagento 2 - Sales Order Shipment Event/ObserverMagento 2 - Why does `sales_order_save_commit_after` not fire when user is not logged in?













0















We have two modules which fire the same event checkout_submit_all_after.But i need to give a preference for this , i tried giving sequence in module b but it won't work.For ex Module A and Module B triggers the same event, but module B triggers first, my requirement is to trigger Module A and after Module B , is there any way i can do this. And what are the events triggers when order is placed through cron jobs, I have used checkout_submit_all_after, does this event fires if the order is placed through crons?.



Please give me any solution for to go forward.
Thank You










share|improve this question




























    0















    We have two modules which fire the same event checkout_submit_all_after.But i need to give a preference for this , i tried giving sequence in module b but it won't work.For ex Module A and Module B triggers the same event, but module B triggers first, my requirement is to trigger Module A and after Module B , is there any way i can do this. And what are the events triggers when order is placed through cron jobs, I have used checkout_submit_all_after, does this event fires if the order is placed through crons?.



    Please give me any solution for to go forward.
    Thank You










    share|improve this question


























      0












      0








      0








      We have two modules which fire the same event checkout_submit_all_after.But i need to give a preference for this , i tried giving sequence in module b but it won't work.For ex Module A and Module B triggers the same event, but module B triggers first, my requirement is to trigger Module A and after Module B , is there any way i can do this. And what are the events triggers when order is placed through cron jobs, I have used checkout_submit_all_after, does this event fires if the order is placed through crons?.



      Please give me any solution for to go forward.
      Thank You










      share|improve this question
















      We have two modules which fire the same event checkout_submit_all_after.But i need to give a preference for this , i tried giving sequence in module b but it won't work.For ex Module A and Module B triggers the same event, but module B triggers first, my requirement is to trigger Module A and after Module B , is there any way i can do this. And what are the events triggers when order is placed through cron jobs, I have used checkout_submit_all_after, does this event fires if the order is placed through crons?.



      Please give me any solution for to go forward.
      Thank You







      magento2 event-observer dependency sequence






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jun 24 at 7:24









      Amit Bera

      61.7k16 gold badges84 silver badges183 bronze badges




      61.7k16 gold badges84 silver badges183 bronze badges










      asked Jun 23 at 6:27









      PrasanthPrasanth

      419 bronze badges




      419 bronze badges




















          1 Answer
          1






          active

          oldest

          votes


















          0














          At first, question, you want to trigger Module A module observer then fire observer of Module B.



          Then below is my solution is of this case.



          Disable Module B using xml code.



          Then Create around plugin the method ModuleA_ObserverClass::execute(MagentoFrameworkEventObserver $observer) of Observer of module A.



          And on that around Plugin PluginClass::aroundExecute() execute original ModuleA_ObserverClass::execute(MagentoFrameworkEventObserver $observer) and
          using $proceed(ModuleA_ObserverClass $subject,Callable ,$observer)
          And after running of origina method , add new method to PluginClass.



          And on this new method, copy all code of ModuleB: execute and run after $proceed($observer).



          Step1: Disable Observer of Module B



          <event name="checkout_submit_all_after">
          <observer name="ModuleB_Observer_Classs" instance="observerClassNameOfModuleB" />
          </event>


          Assume above one is observer declaration of ModuleB. First, we have to disable this observer.



          Let's create An events.xml at your custom module and disable this by XML node disabled.



          <?xml version="1.0"?>
          <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
          <event name="checkout_submit_all_after">
          <!-- Note that observer name should be same of Module B observer -->
          <observer name="ModuleB_Observer_Classs" disabled="true" />
          </event>
          </config>


          Step2: Create around plugin on ModuleA_ObserverClass::execute()



          Create di.xml and declare the around plugin for ModuleA_ObserverClass::execute(MagentoFrameworkEventObserver $observer).



          <?xml version="1.0" ?>
          <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
          <type name="ModuleA_ObserverClass">
          <plugin name="ModuleA_ObserverClass_My_plugin" sortOrder="10" type="PluginClass"/>
          </type>
          </config>


          And Plugin code:



          <?php

          namespace Namespace;


          class PluginClass

          public function aroundExecute(
          ModuleA_Observer_Classs $subject,
          callable $proceed,
          MagentoFrameworkEventObserver $observer
          )
          //This code run original Merthod
          $proceed($observer);
          $this->replicatedMethodExecuteofObseverOfModuleB($observer);


          public function replicatedMethodExecuteofObseverOfModuleB($observer)

          // Copy all code of `ModuleA_ObserverClass::execute(MagentoFrameworkEventObserver $observer)`
          // and paste here







          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',
            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%2f279286%2fmagento-2-module-observer-sequence-order-and-sales-order-event%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














            At first, question, you want to trigger Module A module observer then fire observer of Module B.



            Then below is my solution is of this case.



            Disable Module B using xml code.



            Then Create around plugin the method ModuleA_ObserverClass::execute(MagentoFrameworkEventObserver $observer) of Observer of module A.



            And on that around Plugin PluginClass::aroundExecute() execute original ModuleA_ObserverClass::execute(MagentoFrameworkEventObserver $observer) and
            using $proceed(ModuleA_ObserverClass $subject,Callable ,$observer)
            And after running of origina method , add new method to PluginClass.



            And on this new method, copy all code of ModuleB: execute and run after $proceed($observer).



            Step1: Disable Observer of Module B



            <event name="checkout_submit_all_after">
            <observer name="ModuleB_Observer_Classs" instance="observerClassNameOfModuleB" />
            </event>


            Assume above one is observer declaration of ModuleB. First, we have to disable this observer.



            Let's create An events.xml at your custom module and disable this by XML node disabled.



            <?xml version="1.0"?>
            <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
            <event name="checkout_submit_all_after">
            <!-- Note that observer name should be same of Module B observer -->
            <observer name="ModuleB_Observer_Classs" disabled="true" />
            </event>
            </config>


            Step2: Create around plugin on ModuleA_ObserverClass::execute()



            Create di.xml and declare the around plugin for ModuleA_ObserverClass::execute(MagentoFrameworkEventObserver $observer).



            <?xml version="1.0" ?>
            <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
            <type name="ModuleA_ObserverClass">
            <plugin name="ModuleA_ObserverClass_My_plugin" sortOrder="10" type="PluginClass"/>
            </type>
            </config>


            And Plugin code:



            <?php

            namespace Namespace;


            class PluginClass

            public function aroundExecute(
            ModuleA_Observer_Classs $subject,
            callable $proceed,
            MagentoFrameworkEventObserver $observer
            )
            //This code run original Merthod
            $proceed($observer);
            $this->replicatedMethodExecuteofObseverOfModuleB($observer);


            public function replicatedMethodExecuteofObseverOfModuleB($observer)

            // Copy all code of `ModuleA_ObserverClass::execute(MagentoFrameworkEventObserver $observer)`
            // and paste here







            share|improve this answer





























              0














              At first, question, you want to trigger Module A module observer then fire observer of Module B.



              Then below is my solution is of this case.



              Disable Module B using xml code.



              Then Create around plugin the method ModuleA_ObserverClass::execute(MagentoFrameworkEventObserver $observer) of Observer of module A.



              And on that around Plugin PluginClass::aroundExecute() execute original ModuleA_ObserverClass::execute(MagentoFrameworkEventObserver $observer) and
              using $proceed(ModuleA_ObserverClass $subject,Callable ,$observer)
              And after running of origina method , add new method to PluginClass.



              And on this new method, copy all code of ModuleB: execute and run after $proceed($observer).



              Step1: Disable Observer of Module B



              <event name="checkout_submit_all_after">
              <observer name="ModuleB_Observer_Classs" instance="observerClassNameOfModuleB" />
              </event>


              Assume above one is observer declaration of ModuleB. First, we have to disable this observer.



              Let's create An events.xml at your custom module and disable this by XML node disabled.



              <?xml version="1.0"?>
              <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
              <event name="checkout_submit_all_after">
              <!-- Note that observer name should be same of Module B observer -->
              <observer name="ModuleB_Observer_Classs" disabled="true" />
              </event>
              </config>


              Step2: Create around plugin on ModuleA_ObserverClass::execute()



              Create di.xml and declare the around plugin for ModuleA_ObserverClass::execute(MagentoFrameworkEventObserver $observer).



              <?xml version="1.0" ?>
              <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
              <type name="ModuleA_ObserverClass">
              <plugin name="ModuleA_ObserverClass_My_plugin" sortOrder="10" type="PluginClass"/>
              </type>
              </config>


              And Plugin code:



              <?php

              namespace Namespace;


              class PluginClass

              public function aroundExecute(
              ModuleA_Observer_Classs $subject,
              callable $proceed,
              MagentoFrameworkEventObserver $observer
              )
              //This code run original Merthod
              $proceed($observer);
              $this->replicatedMethodExecuteofObseverOfModuleB($observer);


              public function replicatedMethodExecuteofObseverOfModuleB($observer)

              // Copy all code of `ModuleA_ObserverClass::execute(MagentoFrameworkEventObserver $observer)`
              // and paste here







              share|improve this answer



























                0












                0








                0







                At first, question, you want to trigger Module A module observer then fire observer of Module B.



                Then below is my solution is of this case.



                Disable Module B using xml code.



                Then Create around plugin the method ModuleA_ObserverClass::execute(MagentoFrameworkEventObserver $observer) of Observer of module A.



                And on that around Plugin PluginClass::aroundExecute() execute original ModuleA_ObserverClass::execute(MagentoFrameworkEventObserver $observer) and
                using $proceed(ModuleA_ObserverClass $subject,Callable ,$observer)
                And after running of origina method , add new method to PluginClass.



                And on this new method, copy all code of ModuleB: execute and run after $proceed($observer).



                Step1: Disable Observer of Module B



                <event name="checkout_submit_all_after">
                <observer name="ModuleB_Observer_Classs" instance="observerClassNameOfModuleB" />
                </event>


                Assume above one is observer declaration of ModuleB. First, we have to disable this observer.



                Let's create An events.xml at your custom module and disable this by XML node disabled.



                <?xml version="1.0"?>
                <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
                <event name="checkout_submit_all_after">
                <!-- Note that observer name should be same of Module B observer -->
                <observer name="ModuleB_Observer_Classs" disabled="true" />
                </event>
                </config>


                Step2: Create around plugin on ModuleA_ObserverClass::execute()



                Create di.xml and declare the around plugin for ModuleA_ObserverClass::execute(MagentoFrameworkEventObserver $observer).



                <?xml version="1.0" ?>
                <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
                <type name="ModuleA_ObserverClass">
                <plugin name="ModuleA_ObserverClass_My_plugin" sortOrder="10" type="PluginClass"/>
                </type>
                </config>


                And Plugin code:



                <?php

                namespace Namespace;


                class PluginClass

                public function aroundExecute(
                ModuleA_Observer_Classs $subject,
                callable $proceed,
                MagentoFrameworkEventObserver $observer
                )
                //This code run original Merthod
                $proceed($observer);
                $this->replicatedMethodExecuteofObseverOfModuleB($observer);


                public function replicatedMethodExecuteofObseverOfModuleB($observer)

                // Copy all code of `ModuleA_ObserverClass::execute(MagentoFrameworkEventObserver $observer)`
                // and paste here







                share|improve this answer















                At first, question, you want to trigger Module A module observer then fire observer of Module B.



                Then below is my solution is of this case.



                Disable Module B using xml code.



                Then Create around plugin the method ModuleA_ObserverClass::execute(MagentoFrameworkEventObserver $observer) of Observer of module A.



                And on that around Plugin PluginClass::aroundExecute() execute original ModuleA_ObserverClass::execute(MagentoFrameworkEventObserver $observer) and
                using $proceed(ModuleA_ObserverClass $subject,Callable ,$observer)
                And after running of origina method , add new method to PluginClass.



                And on this new method, copy all code of ModuleB: execute and run after $proceed($observer).



                Step1: Disable Observer of Module B



                <event name="checkout_submit_all_after">
                <observer name="ModuleB_Observer_Classs" instance="observerClassNameOfModuleB" />
                </event>


                Assume above one is observer declaration of ModuleB. First, we have to disable this observer.



                Let's create An events.xml at your custom module and disable this by XML node disabled.



                <?xml version="1.0"?>
                <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
                <event name="checkout_submit_all_after">
                <!-- Note that observer name should be same of Module B observer -->
                <observer name="ModuleB_Observer_Classs" disabled="true" />
                </event>
                </config>


                Step2: Create around plugin on ModuleA_ObserverClass::execute()



                Create di.xml and declare the around plugin for ModuleA_ObserverClass::execute(MagentoFrameworkEventObserver $observer).



                <?xml version="1.0" ?>
                <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
                <type name="ModuleA_ObserverClass">
                <plugin name="ModuleA_ObserverClass_My_plugin" sortOrder="10" type="PluginClass"/>
                </type>
                </config>


                And Plugin code:



                <?php

                namespace Namespace;


                class PluginClass

                public function aroundExecute(
                ModuleA_Observer_Classs $subject,
                callable $proceed,
                MagentoFrameworkEventObserver $observer
                )
                //This code run original Merthod
                $proceed($observer);
                $this->replicatedMethodExecuteofObseverOfModuleB($observer);


                public function replicatedMethodExecuteofObseverOfModuleB($observer)

                // Copy all code of `ModuleA_ObserverClass::execute(MagentoFrameworkEventObserver $observer)`
                // and paste here








                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Jun 24 at 15:17

























                answered Jun 24 at 7:51









                Amit BeraAmit Bera

                61.7k16 gold badges84 silver badges183 bronze badges




                61.7k16 gold badges84 silver badges183 bronze badges



























                    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%2f279286%2fmagento-2-module-observer-sequence-order-and-sales-order-event%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

                    Grendel Contents Story Scholarship Depictions Notes References Navigation menu10.1093/notesj/gjn112Berserkeree

                    Area configuration aggregation error after install Porto themeMagento 2.1 CE Installed but front/backend not loading/workingCSS not loading on page within Magento 2 pageCannot install module in Magento 2no commands defined in the “setup” namespace. in Magento2Magento 2: Static files are present but shows 404Why do i have to always run the commands to clean cache in Magento 2.1.8?Failure reason: 'Unable to unserialize value.'Error 500 after magento migrationIn production mode the site does not loadMagento 2 : Error 500 after installing

                    Middle Expansion Olielle Resaix Definition: Uttering songs of triumph shouting with joy triumphant exulting Sejunction Journal 붙다 달 고급 품목 외출 The stretch trades the screeching tin. Definition: The act of speaking with a drawl a drawl Cough Sand Definition: An uproar a quarrel a noisy outbreak Shake Iron Publicize Horse House Baby 사과 Resaix Flaggy Jelly Temporary Unequaled Puppet A drop in the bucket Shrew 성격 회원 성질 미팅 The burn frames the tacky quality. Materialistic The smoke reduces the way. Yammoe Nondescript Cheek 얼굴 배 약하다 날리다 타다 The illegal country shows the iron. Help Rule Drearien Smoke Teaching Meaty Wasp Abraham Lincoln Jaws 진심 수리하다 Size Cork Idea Convert Think Lark John Lennon 거울 청소 군 추천하다 아이스크림