How to get the items orders by the customer in the order collection? Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?How Can I override Sales_Order_History template in customer section at frontendElement 'css', attribute 'order': The attribute 'order' is not allowedConvert MagentoQuoteModelQuote to MagentoSalesModelOrder: Magento 2How to get all order data using sql?Category order does not work, always sort by the entity_id desc{M1) Product collection sort order by views for Most Viewed ProductsMagento 2.2 Create Order for customer from frontend As Sales RepMagento 2 : How to get order collection group by customer?Get order collection by order id in Magento 2?Get collection of orders excluding cancelled order in Magento 2

White walkers, cemeteries and wights

How to write capital alpha?

Why complex landing gears are used instead of simple,reliability and light weight muscle wire or shape memory alloys?

A proverb that is used to imply that you have unexpectedly faced a big problem

New Order #6: Easter Egg

NERDTreeMenu Remapping

Does the Black Tentacles spell do damage twice at the start of turn to an already restrained creature?

Test print coming out spongy

Does the Mueller report show a conspiracy between Russia and the Trump Campaign?

Putting class ranking in CV, but against dept guidelines

How to ask rejected full-time candidates to apply to teach individual courses?

How many time has Arya actually used Needle?

Tips to organize LaTeX presentations for a semester

Did any compiler fully use 80-bit floating point?

what is the log of the PDF for a Normal Distribution?

What initially awakened the Balrog?

How much damage would a cupful of neutron star matter do to the Earth?

Positioning dot before text in math mode

Why not send Voyager 3 and 4 following up the paths taken by Voyager 1 and 2 to re-transmit signals of later as they fly away from Earth?

Relating to the President and obstruction, were Mueller's conclusions preordained?

I can't produce songs

Universal covering space of the real projective line?

Tannaka duality for semisimple groups

Why do early math courses focus on the cross sections of a cone and not on other 3D objects?



How to get the items orders by the customer in the order collection?



Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)
Announcing the arrival of Valued Associate #679: Cesar Manara
Unicorn Meta Zoo #1: Why another podcast?How Can I override Sales_Order_History template in customer section at frontendElement 'css', attribute 'order': The attribute 'order' is not allowedConvert MagentoQuoteModelQuote to MagentoSalesModelOrder: Magento 2How to get all order data using sql?Category order does not work, always sort by the entity_id desc{M1) Product collection sort order by views for Most Viewed ProductsMagento 2.2 Create Order for customer from frontend As Sales RepMagento 2 : How to get order collection group by customer?Get order collection by order id in Magento 2?Get collection of orders excluding cancelled order in Magento 2



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








0















I need to get the collection of orders with the the items ordered by using the customer ID. But I am not getting the items ordered in my collection. Please help.



 $objectManager = MagentoFrameworkAppObjectManager::getInstance();
$order = $objectManager->create('MagentoSalesModelOrder')->getCollection()->addAttributeToFilter('customer_id', $captinId)->setOrder('entity_id',$direction)->setPageSize($pageSize)->setCurPage($currentPage);
$orderResult = $order->getData();
return $orderResult;









share|improve this question




























    0















    I need to get the collection of orders with the the items ordered by using the customer ID. But I am not getting the items ordered in my collection. Please help.



     $objectManager = MagentoFrameworkAppObjectManager::getInstance();
    $order = $objectManager->create('MagentoSalesModelOrder')->getCollection()->addAttributeToFilter('customer_id', $captinId)->setOrder('entity_id',$direction)->setPageSize($pageSize)->setCurPage($currentPage);
    $orderResult = $order->getData();
    return $orderResult;









    share|improve this question
























      0












      0








      0








      I need to get the collection of orders with the the items ordered by using the customer ID. But I am not getting the items ordered in my collection. Please help.



       $objectManager = MagentoFrameworkAppObjectManager::getInstance();
      $order = $objectManager->create('MagentoSalesModelOrder')->getCollection()->addAttributeToFilter('customer_id', $captinId)->setOrder('entity_id',$direction)->setPageSize($pageSize)->setCurPage($currentPage);
      $orderResult = $order->getData();
      return $orderResult;









      share|improve this question














      I need to get the collection of orders with the the items ordered by using the customer ID. But I am not getting the items ordered in my collection. Please help.



       $objectManager = MagentoFrameworkAppObjectManager::getInstance();
      $order = $objectManager->create('MagentoSalesModelOrder')->getCollection()->addAttributeToFilter('customer_id', $captinId)->setOrder('entity_id',$direction)->setPageSize($pageSize)->setCurPage($currentPage);
      $orderResult = $order->getData();
      return $orderResult;






      magento2.2 sales-order order-collection






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 2 days ago









      Meetali GuptaMeetali Gupta

      587




      587




















          2 Answers
          2






          active

          oldest

          votes


















          1














          Try the following way:



          $captinId = 2;
          $direction = 'ASC';
          $pageSize = 20;
          $currentPage = 1;
          $objectManager = MagentoFrameworkAppObjectManager::getInstance();
          $orderItemCollection = $objectManager->create('MagentoSalesModelResourceModelOrderItemCollection')
          ->setOrder('entity_id', $direction)
          ->setPageSize($pageSize)
          ->setCurPage($currentPage);

          $orderItemCollection->getSelect()->joinLeft(
          'sales_order',
          'sales_order.entity_id=main_table.order_id',
          ['increment_id']
          )->where('sales_order.customer_id=?', $captinId);
          $orderResult = $orderItemCollection->getData();


          Note: Avoid to use MagentoFrameworkAppObjectManager::getInstance()






          share|improve this answer























          • Thanks for the reponse, now I am getting the products but I want to get them as an array of items. Please help me.

            – Meetali Gupta
            2 days ago


















          0














          Please try the code below.



          $objectManager = MagentoFrameworkAppObjectManager::getInstance();
          $lastyear = date('Y-m-d', strtotime("-1 year"));
          $orderCollection = $objectManager->create('MagentoSalesModelResourceModelOrderCollection');
          $orderCollection->addAttributeToFilter('customer_id',123456)
          ->addAttributeToFilter('status','complete')
          ->addAttributeToFilter('created_at', array('gteq' => $lastyear))->load();

          echo "<pre>";print_r($orderCollection->getData()); exit;


          Then you need to load the order items by order ID.



          <?php
          $orderid = 2;

          $objectManager = MagentoFrameworkAppObjectManager::getInstance();
          $order = $objectManager->create('MagentoSalesApiDataOrderInterface')->load($orderid);

          //Loop through each item and fetch data
          foreach ($order->getAllItems() as $item)

          //fetch whole item information
          print_r($item->getData());

          //Or fetch specific item information
          echo $item->getId();
          echo $item->getProductType();
          echo $item->getQtyOrdered();
          echo $item->getPrice();


          ?>





          share|improve this answer

























          • But this also does not get the order items in my response.

            – Meetali Gupta
            2 days ago












          • I have updated the answer.

            – Sudhanshu Bajaj
            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%2f270585%2fhow-to-get-the-items-orders-by-the-customer-in-the-order-collection%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









          1














          Try the following way:



          $captinId = 2;
          $direction = 'ASC';
          $pageSize = 20;
          $currentPage = 1;
          $objectManager = MagentoFrameworkAppObjectManager::getInstance();
          $orderItemCollection = $objectManager->create('MagentoSalesModelResourceModelOrderItemCollection')
          ->setOrder('entity_id', $direction)
          ->setPageSize($pageSize)
          ->setCurPage($currentPage);

          $orderItemCollection->getSelect()->joinLeft(
          'sales_order',
          'sales_order.entity_id=main_table.order_id',
          ['increment_id']
          )->where('sales_order.customer_id=?', $captinId);
          $orderResult = $orderItemCollection->getData();


          Note: Avoid to use MagentoFrameworkAppObjectManager::getInstance()






          share|improve this answer























          • Thanks for the reponse, now I am getting the products but I want to get them as an array of items. Please help me.

            – Meetali Gupta
            2 days ago















          1














          Try the following way:



          $captinId = 2;
          $direction = 'ASC';
          $pageSize = 20;
          $currentPage = 1;
          $objectManager = MagentoFrameworkAppObjectManager::getInstance();
          $orderItemCollection = $objectManager->create('MagentoSalesModelResourceModelOrderItemCollection')
          ->setOrder('entity_id', $direction)
          ->setPageSize($pageSize)
          ->setCurPage($currentPage);

          $orderItemCollection->getSelect()->joinLeft(
          'sales_order',
          'sales_order.entity_id=main_table.order_id',
          ['increment_id']
          )->where('sales_order.customer_id=?', $captinId);
          $orderResult = $orderItemCollection->getData();


          Note: Avoid to use MagentoFrameworkAppObjectManager::getInstance()






          share|improve this answer























          • Thanks for the reponse, now I am getting the products but I want to get them as an array of items. Please help me.

            – Meetali Gupta
            2 days ago













          1












          1








          1







          Try the following way:



          $captinId = 2;
          $direction = 'ASC';
          $pageSize = 20;
          $currentPage = 1;
          $objectManager = MagentoFrameworkAppObjectManager::getInstance();
          $orderItemCollection = $objectManager->create('MagentoSalesModelResourceModelOrderItemCollection')
          ->setOrder('entity_id', $direction)
          ->setPageSize($pageSize)
          ->setCurPage($currentPage);

          $orderItemCollection->getSelect()->joinLeft(
          'sales_order',
          'sales_order.entity_id=main_table.order_id',
          ['increment_id']
          )->where('sales_order.customer_id=?', $captinId);
          $orderResult = $orderItemCollection->getData();


          Note: Avoid to use MagentoFrameworkAppObjectManager::getInstance()






          share|improve this answer













          Try the following way:



          $captinId = 2;
          $direction = 'ASC';
          $pageSize = 20;
          $currentPage = 1;
          $objectManager = MagentoFrameworkAppObjectManager::getInstance();
          $orderItemCollection = $objectManager->create('MagentoSalesModelResourceModelOrderItemCollection')
          ->setOrder('entity_id', $direction)
          ->setPageSize($pageSize)
          ->setCurPage($currentPage);

          $orderItemCollection->getSelect()->joinLeft(
          'sales_order',
          'sales_order.entity_id=main_table.order_id',
          ['increment_id']
          )->where('sales_order.customer_id=?', $captinId);
          $orderResult = $orderItemCollection->getData();


          Note: Avoid to use MagentoFrameworkAppObjectManager::getInstance()







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered 2 days ago









          Sohel RanaSohel Rana

          23.4k34461




          23.4k34461












          • Thanks for the reponse, now I am getting the products but I want to get them as an array of items. Please help me.

            – Meetali Gupta
            2 days ago

















          • Thanks for the reponse, now I am getting the products but I want to get them as an array of items. Please help me.

            – Meetali Gupta
            2 days ago
















          Thanks for the reponse, now I am getting the products but I want to get them as an array of items. Please help me.

          – Meetali Gupta
          2 days ago





          Thanks for the reponse, now I am getting the products but I want to get them as an array of items. Please help me.

          – Meetali Gupta
          2 days ago













          0














          Please try the code below.



          $objectManager = MagentoFrameworkAppObjectManager::getInstance();
          $lastyear = date('Y-m-d', strtotime("-1 year"));
          $orderCollection = $objectManager->create('MagentoSalesModelResourceModelOrderCollection');
          $orderCollection->addAttributeToFilter('customer_id',123456)
          ->addAttributeToFilter('status','complete')
          ->addAttributeToFilter('created_at', array('gteq' => $lastyear))->load();

          echo "<pre>";print_r($orderCollection->getData()); exit;


          Then you need to load the order items by order ID.



          <?php
          $orderid = 2;

          $objectManager = MagentoFrameworkAppObjectManager::getInstance();
          $order = $objectManager->create('MagentoSalesApiDataOrderInterface')->load($orderid);

          //Loop through each item and fetch data
          foreach ($order->getAllItems() as $item)

          //fetch whole item information
          print_r($item->getData());

          //Or fetch specific item information
          echo $item->getId();
          echo $item->getProductType();
          echo $item->getQtyOrdered();
          echo $item->getPrice();


          ?>





          share|improve this answer

























          • But this also does not get the order items in my response.

            – Meetali Gupta
            2 days ago












          • I have updated the answer.

            – Sudhanshu Bajaj
            2 days ago















          0














          Please try the code below.



          $objectManager = MagentoFrameworkAppObjectManager::getInstance();
          $lastyear = date('Y-m-d', strtotime("-1 year"));
          $orderCollection = $objectManager->create('MagentoSalesModelResourceModelOrderCollection');
          $orderCollection->addAttributeToFilter('customer_id',123456)
          ->addAttributeToFilter('status','complete')
          ->addAttributeToFilter('created_at', array('gteq' => $lastyear))->load();

          echo "<pre>";print_r($orderCollection->getData()); exit;


          Then you need to load the order items by order ID.



          <?php
          $orderid = 2;

          $objectManager = MagentoFrameworkAppObjectManager::getInstance();
          $order = $objectManager->create('MagentoSalesApiDataOrderInterface')->load($orderid);

          //Loop through each item and fetch data
          foreach ($order->getAllItems() as $item)

          //fetch whole item information
          print_r($item->getData());

          //Or fetch specific item information
          echo $item->getId();
          echo $item->getProductType();
          echo $item->getQtyOrdered();
          echo $item->getPrice();


          ?>





          share|improve this answer

























          • But this also does not get the order items in my response.

            – Meetali Gupta
            2 days ago












          • I have updated the answer.

            – Sudhanshu Bajaj
            2 days ago













          0












          0








          0







          Please try the code below.



          $objectManager = MagentoFrameworkAppObjectManager::getInstance();
          $lastyear = date('Y-m-d', strtotime("-1 year"));
          $orderCollection = $objectManager->create('MagentoSalesModelResourceModelOrderCollection');
          $orderCollection->addAttributeToFilter('customer_id',123456)
          ->addAttributeToFilter('status','complete')
          ->addAttributeToFilter('created_at', array('gteq' => $lastyear))->load();

          echo "<pre>";print_r($orderCollection->getData()); exit;


          Then you need to load the order items by order ID.



          <?php
          $orderid = 2;

          $objectManager = MagentoFrameworkAppObjectManager::getInstance();
          $order = $objectManager->create('MagentoSalesApiDataOrderInterface')->load($orderid);

          //Loop through each item and fetch data
          foreach ($order->getAllItems() as $item)

          //fetch whole item information
          print_r($item->getData());

          //Or fetch specific item information
          echo $item->getId();
          echo $item->getProductType();
          echo $item->getQtyOrdered();
          echo $item->getPrice();


          ?>





          share|improve this answer















          Please try the code below.



          $objectManager = MagentoFrameworkAppObjectManager::getInstance();
          $lastyear = date('Y-m-d', strtotime("-1 year"));
          $orderCollection = $objectManager->create('MagentoSalesModelResourceModelOrderCollection');
          $orderCollection->addAttributeToFilter('customer_id',123456)
          ->addAttributeToFilter('status','complete')
          ->addAttributeToFilter('created_at', array('gteq' => $lastyear))->load();

          echo "<pre>";print_r($orderCollection->getData()); exit;


          Then you need to load the order items by order ID.



          <?php
          $orderid = 2;

          $objectManager = MagentoFrameworkAppObjectManager::getInstance();
          $order = $objectManager->create('MagentoSalesApiDataOrderInterface')->load($orderid);

          //Loop through each item and fetch data
          foreach ($order->getAllItems() as $item)

          //fetch whole item information
          print_r($item->getData());

          //Or fetch specific item information
          echo $item->getId();
          echo $item->getProductType();
          echo $item->getQtyOrdered();
          echo $item->getPrice();


          ?>






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited 2 days ago

























          answered 2 days ago









          Sudhanshu BajajSudhanshu Bajaj

          172




          172












          • But this also does not get the order items in my response.

            – Meetali Gupta
            2 days ago












          • I have updated the answer.

            – Sudhanshu Bajaj
            2 days ago

















          • But this also does not get the order items in my response.

            – Meetali Gupta
            2 days ago












          • I have updated the answer.

            – Sudhanshu Bajaj
            2 days ago
















          But this also does not get the order items in my response.

          – Meetali Gupta
          2 days ago






          But this also does not get the order items in my response.

          – Meetali Gupta
          2 days ago














          I have updated the answer.

          – Sudhanshu Bajaj
          2 days ago





          I have updated the answer.

          – Sudhanshu Bajaj
          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%2f270585%2fhow-to-get-the-items-orders-by-the-customer-in-the-order-collection%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 거울 청소 군 추천하다 아이스크림