I'm trying to filter by order_item to get a list of orders.

Get all orders where an order item has a price greater than 5.

How would this be done? Collections? Joins?


Use below code to filter order collection based on order item price

    protected $_resourceFactory;

    public function __construct(
        \Magento\Sales\Model\ResourceModel\Order\Item\CollectionFactory $resourceFactory,
    ) {
        $this->_resourceFactory = $resourceFactory;

    public function yourfunction(){
        $collection = $this->_resourceFactory->create();
                   'main_table.order_id = order.entity_id',
                $collection->addFieldToFilter('price',array('gt' => 5));

        return $collection;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.