Get order increment id in observer Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?observer method sales_order_place_after not executingConfusion with order id, order increment id and I am not getting order id as 20001201Can't get order object in sales_order_place_after observer methodHow to change save path of PDF files in magento 2How to save errors through observer on checkout pagesales_order_shipment_save_after fires before shipment actually saved?Unable to get order details using magento 2 rest apiLeft join order grid collection using observer method. Magento 1.9Magento 2: I Want to add multiple product using checkboxHow can Save API respond (For each order request - PDF file) with order id in database?

Will I lose my paid in full property

"Working on a knee"

Bright yellow or light yellow?

Was Objective-C really a hindrance to Apple software development?

Israeli soda type drink

What's the difference between using dependency injection with a container and using a service locator?

In search of the origins of term censor, I hit a dead end stuck with the greek term, to censor, λογοκρίνω

How can I wire a 9-position switch so that each position turns on one more LED than the one before?

Why does the Cisco show run command not show the full version, while the show version command does?

What is a good proxy for government quality?

What is /etc/mtab in Linux?

What was Apollo 13's "Little Jolt" after MECO?

What were wait-states, and why was it only an issue for PCs?

Why does Java have support for time zone offsets with seconds precision?

false 'Security alert' from Google - every login generates mails from 'no-reply@accounts.google.com'

What helicopter has the most rotor blades?

What is the ongoing value of the Kanban board to the developers as opposed to management

Co-worker works way more than he should

France's Public Holidays' Puzzle

Suing a Police Officer Instead of the Police Department

Putting Ant-Man on house arrest

Why isPrototypeOf() returns false?

So I pre ordered a game on my friends home screen but on my Xbox, does that mean I don't get the game and I lost 60$?

RIP Packet Format



Get order increment id in observer



Announcing the arrival of Valued Associate #679: Cesar Manara
Unicorn Meta Zoo #1: Why another podcast?observer method sales_order_place_after not executingConfusion with order id, order increment id and I am not getting order id as 20001201Can't get order object in sales_order_place_after observer methodHow to change save path of PDF files in magento 2How to save errors through observer on checkout pagesales_order_shipment_save_after fires before shipment actually saved?Unable to get order details using magento 2 rest apiLeft join order grid collection using observer method. Magento 1.9Magento 2: I Want to add multiple product using checkboxHow can Save API respond (For each order request - PDF file) with order id in database?



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








1















I have created a module to save order details to a custom mysql table after checkout completion. All works fine but the order id saves in the format "210"(order_id) instead of "1000000210"(increment_id). How can I get this format?
My observer looks like this:



public function execute(Observer $observer)


$orderId = $observer->getEvent()->getOrderIds()[0];
$order = $this->orderRepository->get($orderId);
$this->postSaverModel->create()->doSync($orderId);











share|improve this question






























    1















    I have created a module to save order details to a custom mysql table after checkout completion. All works fine but the order id saves in the format "210"(order_id) instead of "1000000210"(increment_id). How can I get this format?
    My observer looks like this:



    public function execute(Observer $observer)


    $orderId = $observer->getEvent()->getOrderIds()[0];
    $order = $this->orderRepository->get($orderId);
    $this->postSaverModel->create()->doSync($orderId);











    share|improve this question


























      1












      1








      1








      I have created a module to save order details to a custom mysql table after checkout completion. All works fine but the order id saves in the format "210"(order_id) instead of "1000000210"(increment_id). How can I get this format?
      My observer looks like this:



      public function execute(Observer $observer)


      $orderId = $observer->getEvent()->getOrderIds()[0];
      $order = $this->orderRepository->get($orderId);
      $this->postSaverModel->create()->doSync($orderId);











      share|improve this question
















      I have created a module to save order details to a custom mysql table after checkout completion. All works fine but the order id saves in the format "210"(order_id) instead of "1000000210"(increment_id). How can I get this format?
      My observer looks like this:



      public function execute(Observer $observer)


      $orderId = $observer->getEvent()->getOrderIds()[0];
      $order = $this->orderRepository->get($orderId);
      $this->postSaverModel->create()->doSync($orderId);








      magento2 event-observer sales-order






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited yesterday









      HelgeB

      3,4481423




      3,4481423










      asked 2 days ago









      Shujaat ShaikhShujaat Shaikh

      277




      277




















          2 Answers
          2






          active

          oldest

          votes


















          2














          You can try below code for get order increment id in observer.



          $order = $observer->getEvent()->getOrder();
          $incrementId = $order->getIncrementId();





          share|improve this answer























          • I have tried this. It does not saves my order data to my custom mysql table though the order is created

            – Shujaat Shaikh
            2 days ago











          • @ShujaatShaikh share your full code you have tried.

            – Kirti Nariya
            2 days ago











          • This did worked. Thanks!

            – Shujaat Shaikh
            2 days ago


















          0














          Why you get order object again in your execute function ? You can get order object in your observer using this below code and get increment id also :



          $order = $observer->getEvent()->getOrder(); // Order object
          $order_incrementId = $order->getIncrementId(); //Increment Id





          share|improve this answer























          • I have tried this. It does not saves my order data to my custom mysql table though the order is created

            – Shujaat Shaikh
            2 days ago











          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%2f270872%2fget-order-increment-id-in-observer%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          2














          You can try below code for get order increment id in observer.



          $order = $observer->getEvent()->getOrder();
          $incrementId = $order->getIncrementId();





          share|improve this answer























          • I have tried this. It does not saves my order data to my custom mysql table though the order is created

            – Shujaat Shaikh
            2 days ago











          • @ShujaatShaikh share your full code you have tried.

            – Kirti Nariya
            2 days ago











          • This did worked. Thanks!

            – Shujaat Shaikh
            2 days ago















          2














          You can try below code for get order increment id in observer.



          $order = $observer->getEvent()->getOrder();
          $incrementId = $order->getIncrementId();





          share|improve this answer























          • I have tried this. It does not saves my order data to my custom mysql table though the order is created

            – Shujaat Shaikh
            2 days ago











          • @ShujaatShaikh share your full code you have tried.

            – Kirti Nariya
            2 days ago











          • This did worked. Thanks!

            – Shujaat Shaikh
            2 days ago













          2












          2








          2







          You can try below code for get order increment id in observer.



          $order = $observer->getEvent()->getOrder();
          $incrementId = $order->getIncrementId();





          share|improve this answer













          You can try below code for get order increment id in observer.



          $order = $observer->getEvent()->getOrder();
          $incrementId = $order->getIncrementId();






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered 2 days ago









          Kirti NariyaKirti Nariya

          1,262416




          1,262416












          • I have tried this. It does not saves my order data to my custom mysql table though the order is created

            – Shujaat Shaikh
            2 days ago











          • @ShujaatShaikh share your full code you have tried.

            – Kirti Nariya
            2 days ago











          • This did worked. Thanks!

            – Shujaat Shaikh
            2 days ago

















          • I have tried this. It does not saves my order data to my custom mysql table though the order is created

            – Shujaat Shaikh
            2 days ago











          • @ShujaatShaikh share your full code you have tried.

            – Kirti Nariya
            2 days ago











          • This did worked. Thanks!

            – Shujaat Shaikh
            2 days ago
















          I have tried this. It does not saves my order data to my custom mysql table though the order is created

          – Shujaat Shaikh
          2 days ago





          I have tried this. It does not saves my order data to my custom mysql table though the order is created

          – Shujaat Shaikh
          2 days ago













          @ShujaatShaikh share your full code you have tried.

          – Kirti Nariya
          2 days ago





          @ShujaatShaikh share your full code you have tried.

          – Kirti Nariya
          2 days ago













          This did worked. Thanks!

          – Shujaat Shaikh
          2 days ago





          This did worked. Thanks!

          – Shujaat Shaikh
          2 days ago













          0














          Why you get order object again in your execute function ? You can get order object in your observer using this below code and get increment id also :



          $order = $observer->getEvent()->getOrder(); // Order object
          $order_incrementId = $order->getIncrementId(); //Increment Id





          share|improve this answer























          • I have tried this. It does not saves my order data to my custom mysql table though the order is created

            – Shujaat Shaikh
            2 days ago















          0














          Why you get order object again in your execute function ? You can get order object in your observer using this below code and get increment id also :



          $order = $observer->getEvent()->getOrder(); // Order object
          $order_incrementId = $order->getIncrementId(); //Increment Id





          share|improve this answer























          • I have tried this. It does not saves my order data to my custom mysql table though the order is created

            – Shujaat Shaikh
            2 days ago













          0












          0








          0







          Why you get order object again in your execute function ? You can get order object in your observer using this below code and get increment id also :



          $order = $observer->getEvent()->getOrder(); // Order object
          $order_incrementId = $order->getIncrementId(); //Increment Id





          share|improve this answer













          Why you get order object again in your execute function ? You can get order object in your observer using this below code and get increment id also :



          $order = $observer->getEvent()->getOrder(); // Order object
          $order_incrementId = $order->getIncrementId(); //Increment Id






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered 2 days ago









          Rohan HapaniRohan Hapani

          7,12631865




          7,12631865












          • I have tried this. It does not saves my order data to my custom mysql table though the order is created

            – Shujaat Shaikh
            2 days ago

















          • I have tried this. It does not saves my order data to my custom mysql table though the order is created

            – Shujaat Shaikh
            2 days ago
















          I have tried this. It does not saves my order data to my custom mysql table though the order is created

          – Shujaat Shaikh
          2 days ago





          I have tried this. It does not saves my order data to my custom mysql table though the order is created

          – Shujaat Shaikh
          2 days ago

















          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%2f270872%2fget-order-increment-id-in-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?