I'm learning Magento 2 and got a headache while trying to find how to get all orders from customer.
With Magento 1.x, we can get all orders from customer with the below code.
$yourCustomerId = '123123'; $field = 'customer_id'; $collection = Mage::getModel("sales/order")->getCollection() ->addAttributeToSelect('*') ->addFieldToFilter($field, $yourCustomerId);
Anyone out there can please show me the correct way in 2.x version?
I want to get the orders from customer (
Magento\Customer\Model\Data\Customer) event observer.