Get all orders of customer by email id Magento 2Not getting NULL value or empty value when the filter fails.Why?Magento send orders email to randomHow to get name and email address of all the customer from beginning of the store?Get All Orders from DatabaseMagento: How to get customer last order by joining customers and orders?Magento 2: How to override newsletter Subscriber modelmagento 2 place order programmatically from controllerMagento 2 get custom attribute of a single product inside a pluginMagento 2 How to disable price from orders, customer account and order view if custom module is enabled?Magento 2 plugin change price of products that have a custom attribute with
How to cope with regret and shame about not fully utilizing opportunities during PhD?
Why are solar panels kept tilted?
Does SQL Server allow (make visible) DDL inside a transaction to the transaction prior to commit?
Wireless headphones interfere with Wi-Fi signal on laptop
Trim trailing zeroes off a number extracted by jq
How exactly does artificial gravity work?
Does gravity affect the time evolution of a QM wave function?
Why is it harder to turn a motor/generator with shorted terminals?
Do Life Drain attacks from wights stack?
Determine the slope and write the Cartesian equation of the line.
Why was Thor doubtful about his worthiness to Mjolnir?
Why did the metro bus stop at each railway crossing, despite no warning indicating a train was coming?
Effects of ~10atm pressure on engine design
Smallest Guaranteed hash collision cycle length
Ito`s Lemma problem
Why does lemon juice reduce the "fish" odor of sea food — specifically fish?
Do I need to say 'o`clock'?
Find hamming distance between two Strings of equal length in Java
Magento 2: How to get type columns of table in sql?
What kind of SATA connector is this?
How to distinguish PICTURE OF ME and PICTURE OF MINE in Chinese?
Developers demotivated due to working on same project for more than 2 years
Newly installed programs always appear with external drives in Finder
Unexpected Netflix account registered to my Gmail address - any way it could be a hack attempt?
Get all orders of customer by email id Magento 2
Not getting NULL value or empty value when the filter fails.Why?Magento send orders email to randomHow to get name and email address of all the customer from beginning of the store?Get All Orders from DatabaseMagento: How to get customer last order by joining customers and orders?Magento 2: How to override newsletter Subscriber modelmagento 2 place order programmatically from controllerMagento 2 get custom attribute of a single product inside a pluginMagento 2 How to disable price from orders, customer account and order view if custom module is enabled?Magento 2 plugin change price of products that have a custom attribute with
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
How can I get all orders of a customer via his/her email id who is logged in,
I am using current session to get user's email id
public function getCustomerData()
if ($this->_customerSession->isLoggedIn())
return $this->_customerSession->getCustomerData();
return false;
In phtml
$customerData = $block->getCustomerData();
if($customerData)
echo 'Customer Email: ' . $customerData->getEmail() . '<br/>';
Earlier I was getting my orders information by order id
public function getOrderInformation($orderid)
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$order = $objectManager->create('MagentoSalesApiOrderRepositoryInterface')->get($orderid);
return $order;
How can I get all orders by customer email id
magento2 orders sales-order magento2.3 order-email
add a comment |
How can I get all orders of a customer via his/her email id who is logged in,
I am using current session to get user's email id
public function getCustomerData()
if ($this->_customerSession->isLoggedIn())
return $this->_customerSession->getCustomerData();
return false;
In phtml
$customerData = $block->getCustomerData();
if($customerData)
echo 'Customer Email: ' . $customerData->getEmail() . '<br/>';
Earlier I was getting my orders information by order id
public function getOrderInformation($orderid)
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$order = $objectManager->create('MagentoSalesApiOrderRepositoryInterface')->get($orderid);
return $order;
How can I get all orders by customer email id
magento2 orders sales-order magento2.3 order-email
add a comment |
How can I get all orders of a customer via his/her email id who is logged in,
I am using current session to get user's email id
public function getCustomerData()
if ($this->_customerSession->isLoggedIn())
return $this->_customerSession->getCustomerData();
return false;
In phtml
$customerData = $block->getCustomerData();
if($customerData)
echo 'Customer Email: ' . $customerData->getEmail() . '<br/>';
Earlier I was getting my orders information by order id
public function getOrderInformation($orderid)
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$order = $objectManager->create('MagentoSalesApiOrderRepositoryInterface')->get($orderid);
return $order;
How can I get all orders by customer email id
magento2 orders sales-order magento2.3 order-email
How can I get all orders of a customer via his/her email id who is logged in,
I am using current session to get user's email id
public function getCustomerData()
if ($this->_customerSession->isLoggedIn())
return $this->_customerSession->getCustomerData();
return false;
In phtml
$customerData = $block->getCustomerData();
if($customerData)
echo 'Customer Email: ' . $customerData->getEmail() . '<br/>';
Earlier I was getting my orders information by order id
public function getOrderInformation($orderid)
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$order = $objectManager->create('MagentoSalesApiOrderRepositoryInterface')->get($orderid);
return $order;
How can I get all orders by customer email id
magento2 orders sales-order magento2.3 order-email
magento2 orders sales-order magento2.3 order-email
edited May 9 at 5:58
Muhammad Hasham
3,80231656
3,80231656
asked Feb 15 at 4:38
summusummu
17710
17710
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$resource = $objectManager->get('MagentoFrameworkAppResourceConnection');
$connection = $resource->getConnection();
//*****************loading Customer session *****************//
$customerSession = $objectManager->create('MagentoCustomerModelSession');
//******** Checking whether customer is logged in or not ********//
if ($customerSession->isLoggedIn())
$customer_email = $customerSession->getCustomer()->getEmail();
// ***********Getting order collection using customer email id ***********//
$order_collection = $objectManager->create('MagentoSalesModelOrder')->getCollection()->addAttributeToFilter('customer_email', $customer_email);
//echo "<pre>";print_r($order_collection->getData());
foreach ($order_collection as $order)
echo "Order Id: ".$order->getEntityId();
echo "Customer Id: ".$order->getCustomerId();
Order collection based on logged in Customer Email Id (Customer All orders)
I hope this will help
how to get entity id and customer id from $order_collection->getData() my output is like this . Array ( [0] => Array ( [entity_id] => 166952 ) ) customerid 12004 . , what kind of format is this its not json for sure
– summu
Feb 15 at 10:22
i get this error . Call to undefined method MagentoSalesModelResourceModelOrderCollection::getEntityId()
– summu
Feb 15 at 10:29
foreach ($order_collection as $order) echo "Order Id: ".$order->getEntityId(); echo "Customer Id: ".$order->getCustomerId(); try this
– Muhammad Hasham
Feb 15 at 10:33
add a comment |
Try this,
<?php
namespace VendorModuleControllerOrders;
class ReadOrders extends MagentoFrameworkAppActionAction
public function __construct(
MagentoFrameworkAppActionContext $context,
MagentoSalesModelResourceModelOrderCollectionFactory $orderCollectionFactory,
MagentoCustomerModelSessionFactory $customerSession)
$this->_customerSession = $customerSession->create();
$this->orderCollectionFactory = $orderCollectionFactory;
parent::__construct($context);
public function getCustomerData()
if ($this->_customerSession->isLoggedIn())
return $this->_customerSession->getCustomerData()->getEmail();
public function execute()
if (!$this->_customerSession->isLoggedIn())
return;
$orders = $this->orderCollectionFactory->create()
->addAttributeToFilter('customer_email', $this->getCustomerData());
foreach ($orders as $items)
echo $items->getCustomerEmail() . '<pre>';
Hope this help, if you need any other information. Let me know.
Peace :)
1
Nice effort. +1
– Muhammad Hasham
Mar 28 at 9:59
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%2f261912%2fget-all-orders-of-customer-by-email-id-magento-2%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
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$resource = $objectManager->get('MagentoFrameworkAppResourceConnection');
$connection = $resource->getConnection();
//*****************loading Customer session *****************//
$customerSession = $objectManager->create('MagentoCustomerModelSession');
//******** Checking whether customer is logged in or not ********//
if ($customerSession->isLoggedIn())
$customer_email = $customerSession->getCustomer()->getEmail();
// ***********Getting order collection using customer email id ***********//
$order_collection = $objectManager->create('MagentoSalesModelOrder')->getCollection()->addAttributeToFilter('customer_email', $customer_email);
//echo "<pre>";print_r($order_collection->getData());
foreach ($order_collection as $order)
echo "Order Id: ".$order->getEntityId();
echo "Customer Id: ".$order->getCustomerId();
Order collection based on logged in Customer Email Id (Customer All orders)
I hope this will help
how to get entity id and customer id from $order_collection->getData() my output is like this . Array ( [0] => Array ( [entity_id] => 166952 ) ) customerid 12004 . , what kind of format is this its not json for sure
– summu
Feb 15 at 10:22
i get this error . Call to undefined method MagentoSalesModelResourceModelOrderCollection::getEntityId()
– summu
Feb 15 at 10:29
foreach ($order_collection as $order) echo "Order Id: ".$order->getEntityId(); echo "Customer Id: ".$order->getCustomerId(); try this
– Muhammad Hasham
Feb 15 at 10:33
add a comment |
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$resource = $objectManager->get('MagentoFrameworkAppResourceConnection');
$connection = $resource->getConnection();
//*****************loading Customer session *****************//
$customerSession = $objectManager->create('MagentoCustomerModelSession');
//******** Checking whether customer is logged in or not ********//
if ($customerSession->isLoggedIn())
$customer_email = $customerSession->getCustomer()->getEmail();
// ***********Getting order collection using customer email id ***********//
$order_collection = $objectManager->create('MagentoSalesModelOrder')->getCollection()->addAttributeToFilter('customer_email', $customer_email);
//echo "<pre>";print_r($order_collection->getData());
foreach ($order_collection as $order)
echo "Order Id: ".$order->getEntityId();
echo "Customer Id: ".$order->getCustomerId();
Order collection based on logged in Customer Email Id (Customer All orders)
I hope this will help
how to get entity id and customer id from $order_collection->getData() my output is like this . Array ( [0] => Array ( [entity_id] => 166952 ) ) customerid 12004 . , what kind of format is this its not json for sure
– summu
Feb 15 at 10:22
i get this error . Call to undefined method MagentoSalesModelResourceModelOrderCollection::getEntityId()
– summu
Feb 15 at 10:29
foreach ($order_collection as $order) echo "Order Id: ".$order->getEntityId(); echo "Customer Id: ".$order->getCustomerId(); try this
– Muhammad Hasham
Feb 15 at 10:33
add a comment |
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$resource = $objectManager->get('MagentoFrameworkAppResourceConnection');
$connection = $resource->getConnection();
//*****************loading Customer session *****************//
$customerSession = $objectManager->create('MagentoCustomerModelSession');
//******** Checking whether customer is logged in or not ********//
if ($customerSession->isLoggedIn())
$customer_email = $customerSession->getCustomer()->getEmail();
// ***********Getting order collection using customer email id ***********//
$order_collection = $objectManager->create('MagentoSalesModelOrder')->getCollection()->addAttributeToFilter('customer_email', $customer_email);
//echo "<pre>";print_r($order_collection->getData());
foreach ($order_collection as $order)
echo "Order Id: ".$order->getEntityId();
echo "Customer Id: ".$order->getCustomerId();
Order collection based on logged in Customer Email Id (Customer All orders)
I hope this will help
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$resource = $objectManager->get('MagentoFrameworkAppResourceConnection');
$connection = $resource->getConnection();
//*****************loading Customer session *****************//
$customerSession = $objectManager->create('MagentoCustomerModelSession');
//******** Checking whether customer is logged in or not ********//
if ($customerSession->isLoggedIn())
$customer_email = $customerSession->getCustomer()->getEmail();
// ***********Getting order collection using customer email id ***********//
$order_collection = $objectManager->create('MagentoSalesModelOrder')->getCollection()->addAttributeToFilter('customer_email', $customer_email);
//echo "<pre>";print_r($order_collection->getData());
foreach ($order_collection as $order)
echo "Order Id: ".$order->getEntityId();
echo "Customer Id: ".$order->getCustomerId();
Order collection based on logged in Customer Email Id (Customer All orders)
I hope this will help
edited Feb 15 at 10:40
answered Feb 15 at 4:55
Muhammad HashamMuhammad Hasham
3,80231656
3,80231656
how to get entity id and customer id from $order_collection->getData() my output is like this . Array ( [0] => Array ( [entity_id] => 166952 ) ) customerid 12004 . , what kind of format is this its not json for sure
– summu
Feb 15 at 10:22
i get this error . Call to undefined method MagentoSalesModelResourceModelOrderCollection::getEntityId()
– summu
Feb 15 at 10:29
foreach ($order_collection as $order) echo "Order Id: ".$order->getEntityId(); echo "Customer Id: ".$order->getCustomerId(); try this
– Muhammad Hasham
Feb 15 at 10:33
add a comment |
how to get entity id and customer id from $order_collection->getData() my output is like this . Array ( [0] => Array ( [entity_id] => 166952 ) ) customerid 12004 . , what kind of format is this its not json for sure
– summu
Feb 15 at 10:22
i get this error . Call to undefined method MagentoSalesModelResourceModelOrderCollection::getEntityId()
– summu
Feb 15 at 10:29
foreach ($order_collection as $order) echo "Order Id: ".$order->getEntityId(); echo "Customer Id: ".$order->getCustomerId(); try this
– Muhammad Hasham
Feb 15 at 10:33
how to get entity id and customer id from $order_collection->getData() my output is like this . Array ( [0] => Array ( [entity_id] => 166952 ) ) customerid 12004 . , what kind of format is this its not json for sure
– summu
Feb 15 at 10:22
how to get entity id and customer id from $order_collection->getData() my output is like this . Array ( [0] => Array ( [entity_id] => 166952 ) ) customerid 12004 . , what kind of format is this its not json for sure
– summu
Feb 15 at 10:22
i get this error . Call to undefined method MagentoSalesModelResourceModelOrderCollection::getEntityId()
– summu
Feb 15 at 10:29
i get this error . Call to undefined method MagentoSalesModelResourceModelOrderCollection::getEntityId()
– summu
Feb 15 at 10:29
foreach ($order_collection as $order) echo "Order Id: ".$order->getEntityId(); echo "Customer Id: ".$order->getCustomerId(); try this
– Muhammad Hasham
Feb 15 at 10:33
foreach ($order_collection as $order) echo "Order Id: ".$order->getEntityId(); echo "Customer Id: ".$order->getCustomerId(); try this
– Muhammad Hasham
Feb 15 at 10:33
add a comment |
Try this,
<?php
namespace VendorModuleControllerOrders;
class ReadOrders extends MagentoFrameworkAppActionAction
public function __construct(
MagentoFrameworkAppActionContext $context,
MagentoSalesModelResourceModelOrderCollectionFactory $orderCollectionFactory,
MagentoCustomerModelSessionFactory $customerSession)
$this->_customerSession = $customerSession->create();
$this->orderCollectionFactory = $orderCollectionFactory;
parent::__construct($context);
public function getCustomerData()
if ($this->_customerSession->isLoggedIn())
return $this->_customerSession->getCustomerData()->getEmail();
public function execute()
if (!$this->_customerSession->isLoggedIn())
return;
$orders = $this->orderCollectionFactory->create()
->addAttributeToFilter('customer_email', $this->getCustomerData());
foreach ($orders as $items)
echo $items->getCustomerEmail() . '<pre>';
Hope this help, if you need any other information. Let me know.
Peace :)
1
Nice effort. +1
– Muhammad Hasham
Mar 28 at 9:59
add a comment |
Try this,
<?php
namespace VendorModuleControllerOrders;
class ReadOrders extends MagentoFrameworkAppActionAction
public function __construct(
MagentoFrameworkAppActionContext $context,
MagentoSalesModelResourceModelOrderCollectionFactory $orderCollectionFactory,
MagentoCustomerModelSessionFactory $customerSession)
$this->_customerSession = $customerSession->create();
$this->orderCollectionFactory = $orderCollectionFactory;
parent::__construct($context);
public function getCustomerData()
if ($this->_customerSession->isLoggedIn())
return $this->_customerSession->getCustomerData()->getEmail();
public function execute()
if (!$this->_customerSession->isLoggedIn())
return;
$orders = $this->orderCollectionFactory->create()
->addAttributeToFilter('customer_email', $this->getCustomerData());
foreach ($orders as $items)
echo $items->getCustomerEmail() . '<pre>';
Hope this help, if you need any other information. Let me know.
Peace :)
1
Nice effort. +1
– Muhammad Hasham
Mar 28 at 9:59
add a comment |
Try this,
<?php
namespace VendorModuleControllerOrders;
class ReadOrders extends MagentoFrameworkAppActionAction
public function __construct(
MagentoFrameworkAppActionContext $context,
MagentoSalesModelResourceModelOrderCollectionFactory $orderCollectionFactory,
MagentoCustomerModelSessionFactory $customerSession)
$this->_customerSession = $customerSession->create();
$this->orderCollectionFactory = $orderCollectionFactory;
parent::__construct($context);
public function getCustomerData()
if ($this->_customerSession->isLoggedIn())
return $this->_customerSession->getCustomerData()->getEmail();
public function execute()
if (!$this->_customerSession->isLoggedIn())
return;
$orders = $this->orderCollectionFactory->create()
->addAttributeToFilter('customer_email', $this->getCustomerData());
foreach ($orders as $items)
echo $items->getCustomerEmail() . '<pre>';
Hope this help, if you need any other information. Let me know.
Peace :)
Try this,
<?php
namespace VendorModuleControllerOrders;
class ReadOrders extends MagentoFrameworkAppActionAction
public function __construct(
MagentoFrameworkAppActionContext $context,
MagentoSalesModelResourceModelOrderCollectionFactory $orderCollectionFactory,
MagentoCustomerModelSessionFactory $customerSession)
$this->_customerSession = $customerSession->create();
$this->orderCollectionFactory = $orderCollectionFactory;
parent::__construct($context);
public function getCustomerData()
if ($this->_customerSession->isLoggedIn())
return $this->_customerSession->getCustomerData()->getEmail();
public function execute()
if (!$this->_customerSession->isLoggedIn())
return;
$orders = $this->orderCollectionFactory->create()
->addAttributeToFilter('customer_email', $this->getCustomerData());
foreach ($orders as $items)
echo $items->getCustomerEmail() . '<pre>';
Hope this help, if you need any other information. Let me know.
Peace :)
answered Feb 15 at 7:20
Prathap GunasekaranPrathap Gunasekaran
2,1241721
2,1241721
1
Nice effort. +1
– Muhammad Hasham
Mar 28 at 9:59
add a comment |
1
Nice effort. +1
– Muhammad Hasham
Mar 28 at 9:59
1
1
Nice effort. +1
– Muhammad Hasham
Mar 28 at 9:59
Nice effort. +1
– Muhammad Hasham
Mar 28 at 9:59
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%2f261912%2fget-all-orders-of-customer-by-email-id-magento-2%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