- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2017
12:11 PM
08-22-2017
12:11 PM
How do we load all orders for a specific customer in Magento?
This is how we did in in Magento 1.
Thank you.
$orderCollection = Mage::getModel('sales/order')->getCollection(); $lastyear = date('Y-m-d', strtotime("-1 year")); $orders = $orderCollection->addAttributeToFilter("customer_id", 123456)->addAttributeToFilter('state', 'complete')->addAttributeToFilter('created_at', array('gteq' => $lastyear));
Solved! Go to Solution.
Labels:
1 ACCEPTED SOLUTION
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2017
10:07 PM
08-22-2017
10:07 PM
You can call Specific customer order based on customer id from below way,
$objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $lastyear = date('Y-m-d', strtotime("-1 year")); $orderCollection = $objectManager->create('\Magento\Sales\Model\ResourceModel\Order\Collection'); $orderCollection->addAttributeToFilter('customer_id',123456) ->addAttributeToFilter('status','complete') ->addAttributeToFilter('created_at', array('gteq' => $lastyear))->load(); echo "<pre>";print_r($orderCollection->getData()); exit;
if issue solved,Click kudos/Accept as solutions.
If Issue Solved, Click Kudos/Accept As solutions. Get Magento insight from
Magento 2 Blogs/Tutorial
Magento 2 Blogs/Tutorial
4 REPLIES 4
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2017
10:07 PM
08-22-2017
10:07 PM
You can call Specific customer order based on customer id from below way,
$objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $lastyear = date('Y-m-d', strtotime("-1 year")); $orderCollection = $objectManager->create('\Magento\Sales\Model\ResourceModel\Order\Collection'); $orderCollection->addAttributeToFilter('customer_id',123456) ->addAttributeToFilter('status','complete') ->addAttributeToFilter('created_at', array('gteq' => $lastyear))->load(); echo "<pre>";print_r($orderCollection->getData()); exit;
if issue solved,Click kudos/Accept as solutions.
If Issue Solved, Click Kudos/Accept As solutions. Get Magento insight from
Magento 2 Blogs/Tutorial
Magento 2 Blogs/Tutorial
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2017
10:54 AM
08-28-2017
10:54 AM
Re: How to Load all Orders for Specified Customer ID
Fantastic. Worked great. Thank you very much!
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2019
06:02 AM
10-02-2019
06:02 AM
Re: How to Load all Orders for Specified Customer ID
Great solution
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2021
11:33 PM
02-16-2021
11:33 PM
Re: How to Load all Orders for Specified Customer ID
How to Load all Orders for Specified Customer's Phone Number