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

          Get product attribute by attribute group code in magento 2get product attribute by product attribute group in magento 2Magento 2 Log Bundle Product Data in List Page?How to get all product attribute of a attribute group of Default attribute set?Magento 2.1 Create a filter in the product grid by new attributeMagento 2 : Get Product Attribute values By GroupMagento 2 How to get all existing values for one attributeMagento 2 get custom attribute of a single product inside a pluginMagento 2.3 How to get all the Multi Source Inventory (MSI) locations collection in custom module?Magento2: how to develop rest API to get new productsGet product attribute by attribute group code ( [attribute_group_code] ) in magento 2

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

          Magento 2.3: How do i solve this, Not registered handle, on custom form?How can i rewrite TierPrice Block in Magento2magento 2 captcha not rendering if I override layout xmlmain.CRITICAL: Plugin class doesn't existMagento 2 : Problem while adding custom button order view page?Magento 2.2.5: Overriding Admin Controller sales/orderMagento 2.2.5: Add, Update and Delete existing products Custom OptionsMagento 2.3 : File Upload issue in UI Component FormMagento2 Not registered handleHow to configured Form Builder Js in my custom magento 2.3.0 module?Magento 2.3. How to create image upload field in an admin form