Skip to main content
Post Undeleted by Prathap Gunasekaran
Post Deleted by Prathap Gunasekaran
added 10 characters in body
Source Link

Try this,

<?php                                                                 
namespace Vendor\Module\Controller\Orders;                                
class ReadOrders extends \Magento\Framework\App\Action\Action                 
{
public function __construct(
 \Magento\Framework\App\Action\Context $context,
 \Magento\Sales\Api\OrderRepositoryInterface $orderRepo
) {
   $this->orderRepo = $orderRepo;
   parent::__construct($context);
}

public function execute()
{
   $entity_id = '12'; // its called increment id
   $order = $this->orderRepo->get($entity_id);
   echo $order->getCustomerId();
   echo $order->getCustomerFirstname();
   echo $order->getCustomerEmail();
   
} 
}

Don't use object manager anywhere and you can use the above code in block or helper anywhere to get the collection.

Hope this helps.

Try this,

<?php                                                                 
namespace Vendor\Module\Controller\Orders;                                
class ReadOrders extends \Magento\Framework\App\Action\Action                 
{
public function __construct(
 \Magento\Framework\App\Action\Context $context,
 \Magento\Sales\Api\OrderRepositoryInterface $orderRepo
) {
   $this->orderRepo = $orderRepo;
   parent::__construct($context);
}

public function execute()
{
   $entity_id = '12'; // its called increment id
   $order = $this->orderRepo->get($entity_id);
   echo $order->getCustomerId();
   echo $order->getCustomerFirstname();
   echo $order->getCustomerEmail();
   
}}

Don't object manager anywhere and you can use the above code in block or helper anywhere to get the collection.

Hope this helps.

Try this,

<?php                                                                 
namespace Vendor\Module\Controller\Orders;                                
class ReadOrders extends \Magento\Framework\App\Action\Action                 
{
public function __construct(
 \Magento\Framework\App\Action\Context $context,
 \Magento\Sales\Api\OrderRepositoryInterface $orderRepo
) {
   $this->orderRepo = $orderRepo;
   parent::__construct($context);
}

public function execute()
{
   $entity_id = '12'; // its called increment id
   $order = $this->orderRepo->get($entity_id);
   echo $order->getCustomerId();
   echo $order->getCustomerFirstname();
   echo $order->getCustomerEmail();
   
} 
}

Don't use object manager anywhere and you can use the above code in block or helper anywhere to get the collection.

Hope this helps.

Source Link

Try this,

<?php                                                                 
namespace Vendor\Module\Controller\Orders;                                
class ReadOrders extends \Magento\Framework\App\Action\Action                 
{
public function __construct(
 \Magento\Framework\App\Action\Context $context,
 \Magento\Sales\Api\OrderRepositoryInterface $orderRepo
) {
   $this->orderRepo = $orderRepo;
   parent::__construct($context);
}

public function execute()
{
   $entity_id = '12'; // its called increment id
   $order = $this->orderRepo->get($entity_id);
   echo $order->getCustomerId();
   echo $order->getCustomerFirstname();
   echo $order->getCustomerEmail();
   
}}

Don't object manager anywhere and you can use the above code in block or helper anywhere to get the collection.

Hope this helps.