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;
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 2 days ago
Meetali GuptaMeetali Gupta
587
587
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
2 days ago
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
2 days ago
I have updated the answer.
– Sudhanshu Bajaj
2 days ago
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
2 days ago
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
2 days ago
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 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
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
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
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
2 days ago
I have updated the answer.
– Sudhanshu Bajaj
2 days ago
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
2 days ago
I have updated the answer.
– Sudhanshu Bajaj
2 days ago
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 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
add a comment |
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
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