Get order object inside email_order_set_template_vars_before event observerOrder email, how to get the product IdChange Order Confirmation Email For Specific OrdersHow to get cart item details in event observer?Can't get order object in sales_order_place_after observer methodIs it possible to have multiple sales email templates for one site?How to change the email template depending on shipping method?How to set custom value in default Email template Magento 2Which event observer will be triggered before customer mail send in Magento 2?Get Customer from Order inside Observer functionCustom email sent with template empty in observer after order

Way of refund if scammed?

Salesforce bug enabled "Modify All"

What does it mean when みたいな is at the end of a sentence?

Is a world with one country feeding everyone possible?

Are there historical examples of audiences drawn to a work that was "so bad it's good"?

How can I reduce the size of matrix?

Why is unzipped file smaller than zipped file

Can a UK national work as a paid shop assistant in the USA?

How to tease a romance without a cat and mouse chase?

Is there an idiom that means that you are in a very strong negotiation position in a negotiation?

Can diplomats be allowed on the flight deck of a commercial European airline?

Efficient Algorithms for Destroyed Document Reconstruction

Three knights or knaves, three different hair colors

How does the Earth's center produce heat?

Caught with my phone during an exam

Wifi light switch needs neutral wire. Why? AND Can that wire be a skinny one?

Adobe Illustrator: How can I change the profile of a dashed stroke?

Why is this integration method not valid?

What is this dime sized black bug with white on the segments near Loveland Colorodao?

Why did Nick Fury not hesitate in blowing up the plane he thought was carrying a nuke?

Why the work done is positive when bringing 2 opposite charges together?

mmap: effect of other processes writing to a file previously mapped read-only

What is the required burn to keep a satellite at a Lagrangian point?

Computing elements of a 1000 x 60 matrix exhausts RAM



Get order object inside email_order_set_template_vars_before event observer


Order email, how to get the product IdChange Order Confirmation Email For Specific OrdersHow to get cart item details in event observer?Can't get order object in sales_order_place_after observer methodIs it possible to have multiple sales email templates for one site?How to change the email template depending on shipping method?How to set custom value in default Email template Magento 2Which event observer will be triggered before customer mail send in Magento 2?Get Customer from Order inside Observer functionCustom email sent with template empty in observer after order






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








2















I have observer for email_order_set_template_vars_before where i am setting some email template variable to use in order confirmation email.



Now i want to find which products customer has ordered in that order and depending on that set value for email template variable.



So how can i access order object inside this observer method?










share|improve this question




























    2















    I have observer for email_order_set_template_vars_before where i am setting some email template variable to use in order confirmation email.



    Now i want to find which products customer has ordered in that order and depending on that set value for email template variable.



    So how can i access order object inside this observer method?










    share|improve this question
























      2












      2








      2








      I have observer for email_order_set_template_vars_before where i am setting some email template variable to use in order confirmation email.



      Now i want to find which products customer has ordered in that order and depending on that set value for email template variable.



      So how can i access order object inside this observer method?










      share|improve this question














      I have observer for email_order_set_template_vars_before where i am setting some email template variable to use in order confirmation email.



      Now i want to find which products customer has ordered in that order and depending on that set value for email template variable.



      So how can i access order object inside this observer method?







      magento2 event-observer email-templates






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked May 15 at 7:30









      KhushbuKhushbu

      13113




      13113




















          1 Answer
          1






          active

          oldest

          votes


















          0














          I found answer myself. Sharing here so it may help someone.



          We can get Order object inside execute method of observer as below:



          public function execute(MagentoFrameworkEventObserver $observer)


          $transport = $observer->getTransport();
          $order=$transport['order'];
          $orderId=$order->getEntityId(); /** We can call any method of $order as usual **/








          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%2f274649%2fget-order-object-inside-email-order-set-template-vars-before-event-observer%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














            I found answer myself. Sharing here so it may help someone.



            We can get Order object inside execute method of observer as below:



            public function execute(MagentoFrameworkEventObserver $observer)


            $transport = $observer->getTransport();
            $order=$transport['order'];
            $orderId=$order->getEntityId(); /** We can call any method of $order as usual **/








            share|improve this answer



























              0














              I found answer myself. Sharing here so it may help someone.



              We can get Order object inside execute method of observer as below:



              public function execute(MagentoFrameworkEventObserver $observer)


              $transport = $observer->getTransport();
              $order=$transport['order'];
              $orderId=$order->getEntityId(); /** We can call any method of $order as usual **/








              share|improve this answer

























                0












                0








                0







                I found answer myself. Sharing here so it may help someone.



                We can get Order object inside execute method of observer as below:



                public function execute(MagentoFrameworkEventObserver $observer)


                $transport = $observer->getTransport();
                $order=$transport['order'];
                $orderId=$order->getEntityId(); /** We can call any method of $order as usual **/








                share|improve this answer













                I found answer myself. Sharing here so it may help someone.



                We can get Order object inside execute method of observer as below:



                public function execute(MagentoFrameworkEventObserver $observer)


                $transport = $observer->getTransport();
                $order=$transport['order'];
                $orderId=$order->getEntityId(); /** We can call any method of $order as usual **/









                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered May 15 at 8:19









                KhushbuKhushbu

                13113




                13113



























                    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%2f274649%2fget-order-object-inside-email-order-set-template-vars-before-event-observer%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

                    Category:9 (number) SubcategoriesMedia in category "9 (number)"Navigation menuUpload mediaGND ID: 4485639-8Library of Congress authority ID: sh85091979ReasonatorScholiaStatistics

                    Circuit construction for execution of conditional statements using least significant bitHow are two different registers being used as “control”?How exactly is the stated composite state of the two registers being produced using the $R_zz$ controlled rotations?Efficiently performing controlled rotations in HHLWould this quantum algorithm implementation work?How to prepare a superposed states of odd integers from $1$ to $sqrtN$?Why is this implementation of the order finding algorithm not working?Circuit construction for Hamiltonian simulationHow can I invert the least significant bit of a certain term of a superposed state?Implementing an oracleImplementing a controlled sum operation

                    Magento 2 “No Payment Methods” in Admin New OrderHow to integrate Paypal Express Checkout with the Magento APIMagento 1.5 - Sales > Order > edit order and shipping methods disappearAuto Invoice Check/Money Order Payment methodAdd more simple payment methods?Shipping methods not showingWhat should I do to change payment methods if changing the configuration has no effects?1.9 - No Payment Methods showing upMy Payment Methods not Showing for downloadable/virtual product when checkout?Magento2 API to access internal payment methodHow to call an existing payment methods in the registration form?