Magento 2 has order status history inside each order which essentially is just comments related to a order. All of them are stored in one single database table sales_order_status_history. Each comment relates to order by value in column parent_id
which maps to order_id
. I have a set of order id's in an array.
My end goal is to get an array or a collection with comments related to those orders with single query to make it more efficient. I don't want to write direct database queries. I want to utilize collections functionality that I believe allows you to do something like that.
Magento 2 – How to Get Collection of Sales Order Status History Models by Parent ID
collection;magento2
Best Answer
Assuming
$ids
is an array, the collection would need to be filtered like this:This will allow you to filter by an array.