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
Determine the generator of an ideal of ring of integers
Can a Wizard take the Magic Initiate feat and select spells from the Wizard list?
Why these surprising proportionalities of integrals involving odd zeta values?
Would I be safe to drive a 23 year old truck for 7 hours / 450 miles?
Married in secret, can marital status in passport be changed at a later date?
Should man-made satellites feature an intelligent inverted "cow catcher"?
Can this water damage be explained by lack of gutters and grading issues?
What were wait-states, and why was it only an issue for PCs?
tabularx column has extra padding at right?
What could prevent concentrated local exploration?
Why doesn't the university give past final exams' answers?
How to create a command for the "strange m" symbol in latex?
Like totally amazing interchangeable sister outfit accessory swapping or whatever
Protagonist's race is hidden - should I reveal it?
Is there a way to convert Wolfram Language expression to string?
Do chord progressions usually move by fifths?
Can I ask an author to send me his ebook?
How can I introduce the names of fantasy creatures to the reader?
Can gravitational waves pass through a black hole?
What's the connection between Mr. Nancy and fried chicken?
A German immigrant ancestor has a "Registration Affidavit of Alien Enemy" on file. What does that mean exactly?
Is my guitar’s action too high?
Why do C and C++ allow the expression (int) + 4*5?
Who can become a wight?
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;
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
add a comment |
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
add a comment |
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
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
magento2.2 sales-order order-collection
asked Apr 18 at 6:45
Meetali GuptaMeetali Gupta
677
677
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
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()
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
Apr 18 at 9:08
add a comment |
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();
?>
But this also does not get the order items in my response.
– Meetali Gupta
Apr 18 at 7:01
I have updated the answer.
– Sudhanshu Bajaj
Apr 18 at 7:07
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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()
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
Apr 18 at 9:08
add a comment |
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()
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
Apr 18 at 9:08
add a comment |
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()
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()
answered Apr 18 at 7:36
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
Apr 18 at 9:08
add a comment |
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
Apr 18 at 9:08
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
Apr 18 at 9:08
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
Apr 18 at 9:08
add a comment |
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();
?>
But this also does not get the order items in my response.
– Meetali Gupta
Apr 18 at 7:01
I have updated the answer.
– Sudhanshu Bajaj
Apr 18 at 7:07
add a comment |
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();
?>
But this also does not get the order items in my response.
– Meetali Gupta
Apr 18 at 7:01
I have updated the answer.
– Sudhanshu Bajaj
Apr 18 at 7:07
add a comment |
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();
?>
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();
?>
edited Apr 18 at 7:07
answered Apr 18 at 6:52
Sudhanshu BajajSudhanshu Bajaj
232
232
But this also does not get the order items in my response.
– Meetali Gupta
Apr 18 at 7:01
I have updated the answer.
– Sudhanshu Bajaj
Apr 18 at 7:07
add a comment |
But this also does not get the order items in my response.
– Meetali Gupta
Apr 18 at 7:01
I have updated the answer.
– Sudhanshu Bajaj
Apr 18 at 7:07
But this also does not get the order items in my response.
– Meetali Gupta
Apr 18 at 7:01
But this also does not get the order items in my response.
– Meetali Gupta
Apr 18 at 7:01
I have updated the answer.
– Sudhanshu Bajaj
Apr 18 at 7:07
I have updated the answer.
– Sudhanshu Bajaj
Apr 18 at 7:07
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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