Magento 2: How to filter orders by order items

by AJ47   Last Updated July 11, 2019 21:09 PM

In magento 1, I was able to filter orders by the following:

$orderitem = Mage::getModel('sales/order_item')->getCollection();
$orderitem->addFieldToFilter('name',array('like'=>'%'.$value.'%'));  
$ids =array();
foreach($orderitem as $item){
  $ids[] = $item->getOrderId(); //  sales_flat_order_item.order_id = sales_flat_order.entity_id
}
$this->getCollection()->addFieldToFilter("entity_id",array("in",$ids));
return $this;

How would I achieve this in Magento 2.3?



Related Questions


Updated July 14, 2015 13:04 PM

Updated June 26, 2015 19:04 PM

Updated August 11, 2015 17:04 PM

Updated September 27, 2016 09:03 AM

Updated August 02, 2018 15:09 PM