Get order collection by order id in Magento 2?Element 'css', attribute 'order': The attribute 'order' is not allowedMagento 2: Plugin class does not existHow to install extension using composer - Magento EE 2.2 ( Production )Magento2 does n't get the order collection from OrderCollectionFactoryGet Product id in magento2Send Order Shipment Email to CC AddressError during compilation in magento 2.2.2Magento 2, Cannot `getCollection()` from model factoryError in collectionsDeclaration error during compile

How to tell a function to use the default argument values?

What is the most common color to indicate the input-field is disabled?

Zip/Tar file compressed to larger size?

Do UK voters know if their MP will be the Speaker of the House?

How would I stat a creature to be immune to everything but the Magic Missile spell? (just for fun)

A category-like structure without composition?

Do scales need to be in alphabetical order?

ssTTsSTtRrriinInnnnNNNIiinngg

How does a predictive coding aid in lossless compression?

Personal Teleportation: From Rags to Riches

Why is consensus so controversial in Britain?

Am I breaking OOP practice with this architecture?

Is it inappropriate for a student to attend their mentor's dissertation defense?

Is there a hemisphere-neutral way of specifying a season?

Forgetting the musical notes while performing in concert

How much of data wrangling is a data scientist's job?

What about the virus in 12 Monkeys?

How do I handle a potential work/personal life conflict as the manager of one of my friends?

I would say: "You are another teacher", but she is a woman and I am a man

What is a romance in Latin?

Size of subfigure fitting its content (tikzpicture)

Can my sorcerer use a spellbook only to collect spells and scribe scrolls, not cast?

CAST throwing error when run in stored procedure but not when run as raw query

One verb to replace 'be a member of' a club



Get order collection by order id in Magento 2?


Element 'css', attribute 'order': The attribute 'order' is not allowedMagento 2: Plugin class does not existHow to install extension using composer - Magento EE 2.2 ( Production )Magento2 does n't get the order collection from OrderCollectionFactoryGet Product id in magento2Send Order Shipment Email to CC AddressError during compilation in magento 2.2.2Magento 2, Cannot `getCollection()` from model factoryError in collectionsDeclaration error during compile













2















I am trying to get order collection by order id in Magento 2.



Here is my code:



$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$orders = $objectManager->create('MagentoSalesModelOrder')->getCollection()->load($oid);

echo $custLastName= $orders->getCustomerLastname();


But its is giving fatal error:



 Call to undefined method MagentoSalesModelResourceModelOrderCollection::getCustomerLastname()









share|improve this question

















  • 1





    use $orders = $objectManager->create('MagentoSalesModelOrder')->load($oid);

    – bang.nguyen47
    22 hours ago











  • This method does not return customer information. So I need collection of it that provides customer information as well

    – Arshad Hussain
    22 hours ago











  • check my answer just remove getCollection

    – Ronak Rathod
    22 hours ago















2















I am trying to get order collection by order id in Magento 2.



Here is my code:



$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$orders = $objectManager->create('MagentoSalesModelOrder')->getCollection()->load($oid);

echo $custLastName= $orders->getCustomerLastname();


But its is giving fatal error:



 Call to undefined method MagentoSalesModelResourceModelOrderCollection::getCustomerLastname()









share|improve this question

















  • 1





    use $orders = $objectManager->create('MagentoSalesModelOrder')->load($oid);

    – bang.nguyen47
    22 hours ago











  • This method does not return customer information. So I need collection of it that provides customer information as well

    – Arshad Hussain
    22 hours ago











  • check my answer just remove getCollection

    – Ronak Rathod
    22 hours ago













2












2








2








I am trying to get order collection by order id in Magento 2.



Here is my code:



$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$orders = $objectManager->create('MagentoSalesModelOrder')->getCollection()->load($oid);

echo $custLastName= $orders->getCustomerLastname();


But its is giving fatal error:



 Call to undefined method MagentoSalesModelResourceModelOrderCollection::getCustomerLastname()









share|improve this question














I am trying to get order collection by order id in Magento 2.



Here is my code:



$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$orders = $objectManager->create('MagentoSalesModelOrder')->getCollection()->load($oid);

echo $custLastName= $orders->getCustomerLastname();


But its is giving fatal error:



 Call to undefined method MagentoSalesModelResourceModelOrderCollection::getCustomerLastname()






magento2.2 order-collection






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked 22 hours ago









Arshad HussainArshad Hussain

4021826




4021826







  • 1





    use $orders = $objectManager->create('MagentoSalesModelOrder')->load($oid);

    – bang.nguyen47
    22 hours ago











  • This method does not return customer information. So I need collection of it that provides customer information as well

    – Arshad Hussain
    22 hours ago











  • check my answer just remove getCollection

    – Ronak Rathod
    22 hours ago












  • 1





    use $orders = $objectManager->create('MagentoSalesModelOrder')->load($oid);

    – bang.nguyen47
    22 hours ago











  • This method does not return customer information. So I need collection of it that provides customer information as well

    – Arshad Hussain
    22 hours ago











  • check my answer just remove getCollection

    – Ronak Rathod
    22 hours ago







1




1





use $orders = $objectManager->create('MagentoSalesModelOrder')->load($oid);

– bang.nguyen47
22 hours ago





use $orders = $objectManager->create('MagentoSalesModelOrder')->load($oid);

– bang.nguyen47
22 hours ago













This method does not return customer information. So I need collection of it that provides customer information as well

– Arshad Hussain
22 hours ago





This method does not return customer information. So I need collection of it that provides customer information as well

– Arshad Hussain
22 hours ago













check my answer just remove getCollection

– Ronak Rathod
22 hours ago





check my answer just remove getCollection

– Ronak Rathod
22 hours ago










3 Answers
3






active

oldest

votes


















3














Just Remove getCollection :-



$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$orders = $objectManager->create('MagentoSalesModelOrder')->load($oid);

echo $custLastName= $orders->getCustomerLastname();





share|improve this answer























  • It worked. Thanks

    – Arshad Hussain
    22 hours ago


















1














The Following code will easily get Customer details, Billing, Shipping and order totals



 $orderId = 1222;
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$order = $objectManager->create('MagentoSalesModelOrderRepository')->get($orderId);

/*get customer details*/

$custLastName= $orders->getCustomerLastname();
$custFirsrName= $orders->getCustomerFirstname();
$ipaddress=$order->getRemoteIp();
$customer_email=$order->getCustomerEmail();
$customerid=$order->getCustomerId();

/* get Billing details */
$billingaddress=$order->getBillingAddress();
$billingcity=$billingaddress->getCity();
$billingstreet=$billingaddress->getStreet();
$billingpostcode=$billingaddress->getPostcode();
$billingtelephone=$billingaddress->getTelephone();
$billingstate_code=$billingaddress->getRegionCode();

/* get shipping details */

$shippingaddress=$order->getShippingAddress();
$shippingcity=$shippingaddress->getCity();
$shippingstreet=$shippingaddress->getStreet();
$shippingpostcode=$shippingaddress->getPostcode();
$shippingtelephone=$shippingaddress->getTelephone();
$shippingstate_code=$shippingaddress->getRegionCode();

/* get total */

$tax_amount=$order->getTaxAmount();
$total=$order->getGrandTotal();





share|improve this answer






























    0














    try with



    $orders = $objectManager->create('MagentoSalesModelResourceModelOrderCollectionFactory');

    foreach ($orders as $order)
    echo $order->getCustomerLastname();
    echo $order->getData($id);






    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%2f268468%2fget-order-collection-by-order-id-in-magento-2%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      3 Answers
      3






      active

      oldest

      votes








      3 Answers
      3






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      3














      Just Remove getCollection :-



      $objectManager = MagentoFrameworkAppObjectManager::getInstance();
      $orders = $objectManager->create('MagentoSalesModelOrder')->load($oid);

      echo $custLastName= $orders->getCustomerLastname();





      share|improve this answer























      • It worked. Thanks

        – Arshad Hussain
        22 hours ago















      3














      Just Remove getCollection :-



      $objectManager = MagentoFrameworkAppObjectManager::getInstance();
      $orders = $objectManager->create('MagentoSalesModelOrder')->load($oid);

      echo $custLastName= $orders->getCustomerLastname();





      share|improve this answer























      • It worked. Thanks

        – Arshad Hussain
        22 hours ago













      3












      3








      3







      Just Remove getCollection :-



      $objectManager = MagentoFrameworkAppObjectManager::getInstance();
      $orders = $objectManager->create('MagentoSalesModelOrder')->load($oid);

      echo $custLastName= $orders->getCustomerLastname();





      share|improve this answer













      Just Remove getCollection :-



      $objectManager = MagentoFrameworkAppObjectManager::getInstance();
      $orders = $objectManager->create('MagentoSalesModelOrder')->load($oid);

      echo $custLastName= $orders->getCustomerLastname();






      share|improve this answer












      share|improve this answer



      share|improve this answer










      answered 22 hours ago









      Ronak RathodRonak Rathod

      1,018212




      1,018212












      • It worked. Thanks

        – Arshad Hussain
        22 hours ago

















      • It worked. Thanks

        – Arshad Hussain
        22 hours ago
















      It worked. Thanks

      – Arshad Hussain
      22 hours ago





      It worked. Thanks

      – Arshad Hussain
      22 hours ago













      1














      The Following code will easily get Customer details, Billing, Shipping and order totals



       $orderId = 1222;
      $objectManager = MagentoFrameworkAppObjectManager::getInstance();
      $order = $objectManager->create('MagentoSalesModelOrderRepository')->get($orderId);

      /*get customer details*/

      $custLastName= $orders->getCustomerLastname();
      $custFirsrName= $orders->getCustomerFirstname();
      $ipaddress=$order->getRemoteIp();
      $customer_email=$order->getCustomerEmail();
      $customerid=$order->getCustomerId();

      /* get Billing details */
      $billingaddress=$order->getBillingAddress();
      $billingcity=$billingaddress->getCity();
      $billingstreet=$billingaddress->getStreet();
      $billingpostcode=$billingaddress->getPostcode();
      $billingtelephone=$billingaddress->getTelephone();
      $billingstate_code=$billingaddress->getRegionCode();

      /* get shipping details */

      $shippingaddress=$order->getShippingAddress();
      $shippingcity=$shippingaddress->getCity();
      $shippingstreet=$shippingaddress->getStreet();
      $shippingpostcode=$shippingaddress->getPostcode();
      $shippingtelephone=$shippingaddress->getTelephone();
      $shippingstate_code=$shippingaddress->getRegionCode();

      /* get total */

      $tax_amount=$order->getTaxAmount();
      $total=$order->getGrandTotal();





      share|improve this answer



























        1














        The Following code will easily get Customer details, Billing, Shipping and order totals



         $orderId = 1222;
        $objectManager = MagentoFrameworkAppObjectManager::getInstance();
        $order = $objectManager->create('MagentoSalesModelOrderRepository')->get($orderId);

        /*get customer details*/

        $custLastName= $orders->getCustomerLastname();
        $custFirsrName= $orders->getCustomerFirstname();
        $ipaddress=$order->getRemoteIp();
        $customer_email=$order->getCustomerEmail();
        $customerid=$order->getCustomerId();

        /* get Billing details */
        $billingaddress=$order->getBillingAddress();
        $billingcity=$billingaddress->getCity();
        $billingstreet=$billingaddress->getStreet();
        $billingpostcode=$billingaddress->getPostcode();
        $billingtelephone=$billingaddress->getTelephone();
        $billingstate_code=$billingaddress->getRegionCode();

        /* get shipping details */

        $shippingaddress=$order->getShippingAddress();
        $shippingcity=$shippingaddress->getCity();
        $shippingstreet=$shippingaddress->getStreet();
        $shippingpostcode=$shippingaddress->getPostcode();
        $shippingtelephone=$shippingaddress->getTelephone();
        $shippingstate_code=$shippingaddress->getRegionCode();

        /* get total */

        $tax_amount=$order->getTaxAmount();
        $total=$order->getGrandTotal();





        share|improve this answer

























          1












          1








          1







          The Following code will easily get Customer details, Billing, Shipping and order totals



           $orderId = 1222;
          $objectManager = MagentoFrameworkAppObjectManager::getInstance();
          $order = $objectManager->create('MagentoSalesModelOrderRepository')->get($orderId);

          /*get customer details*/

          $custLastName= $orders->getCustomerLastname();
          $custFirsrName= $orders->getCustomerFirstname();
          $ipaddress=$order->getRemoteIp();
          $customer_email=$order->getCustomerEmail();
          $customerid=$order->getCustomerId();

          /* get Billing details */
          $billingaddress=$order->getBillingAddress();
          $billingcity=$billingaddress->getCity();
          $billingstreet=$billingaddress->getStreet();
          $billingpostcode=$billingaddress->getPostcode();
          $billingtelephone=$billingaddress->getTelephone();
          $billingstate_code=$billingaddress->getRegionCode();

          /* get shipping details */

          $shippingaddress=$order->getShippingAddress();
          $shippingcity=$shippingaddress->getCity();
          $shippingstreet=$shippingaddress->getStreet();
          $shippingpostcode=$shippingaddress->getPostcode();
          $shippingtelephone=$shippingaddress->getTelephone();
          $shippingstate_code=$shippingaddress->getRegionCode();

          /* get total */

          $tax_amount=$order->getTaxAmount();
          $total=$order->getGrandTotal();





          share|improve this answer













          The Following code will easily get Customer details, Billing, Shipping and order totals



           $orderId = 1222;
          $objectManager = MagentoFrameworkAppObjectManager::getInstance();
          $order = $objectManager->create('MagentoSalesModelOrderRepository')->get($orderId);

          /*get customer details*/

          $custLastName= $orders->getCustomerLastname();
          $custFirsrName= $orders->getCustomerFirstname();
          $ipaddress=$order->getRemoteIp();
          $customer_email=$order->getCustomerEmail();
          $customerid=$order->getCustomerId();

          /* get Billing details */
          $billingaddress=$order->getBillingAddress();
          $billingcity=$billingaddress->getCity();
          $billingstreet=$billingaddress->getStreet();
          $billingpostcode=$billingaddress->getPostcode();
          $billingtelephone=$billingaddress->getTelephone();
          $billingstate_code=$billingaddress->getRegionCode();

          /* get shipping details */

          $shippingaddress=$order->getShippingAddress();
          $shippingcity=$shippingaddress->getCity();
          $shippingstreet=$shippingaddress->getStreet();
          $shippingpostcode=$shippingaddress->getPostcode();
          $shippingtelephone=$shippingaddress->getTelephone();
          $shippingstate_code=$shippingaddress->getRegionCode();

          /* get total */

          $tax_amount=$order->getTaxAmount();
          $total=$order->getGrandTotal();






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered 22 hours ago









          ARUNPRABAKARAN MARUNPRABAKARAN M

          374112




          374112





















              0














              try with



              $orders = $objectManager->create('MagentoSalesModelResourceModelOrderCollectionFactory');

              foreach ($orders as $order)
              echo $order->getCustomerLastname();
              echo $order->getData($id);






              share|improve this answer



























                0














                try with



                $orders = $objectManager->create('MagentoSalesModelResourceModelOrderCollectionFactory');

                foreach ($orders as $order)
                echo $order->getCustomerLastname();
                echo $order->getData($id);






                share|improve this answer

























                  0












                  0








                  0







                  try with



                  $orders = $objectManager->create('MagentoSalesModelResourceModelOrderCollectionFactory');

                  foreach ($orders as $order)
                  echo $order->getCustomerLastname();
                  echo $order->getData($id);






                  share|improve this answer













                  try with



                  $orders = $objectManager->create('MagentoSalesModelResourceModelOrderCollectionFactory');

                  foreach ($orders as $order)
                  echo $order->getCustomerLastname();
                  echo $order->getData($id);







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered 22 hours ago









                  Olivier Van de VeldeOlivier Van de Velde

                  1




                  1



























                      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%2f268468%2fget-order-collection-by-order-id-in-magento-2%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