Back to Top

Filtering on joined column in Magento 2

Updated 5 March 2024

In this blog, we will see how to do filtering on joined column in Magento 2. We use addFieldToFilter to apply filter on collection. But the addFieldToFilter does not work if we have joined collections. Let’s suppose we have joined order collection to get the order status.
We can add the column from the second table i.e. order status for filter with addFilterToMap method like shown below,

$collection->addFilterToMap('order_status', 'order.status');

After it has been mapped we can apply filter like normal as shown below,

$collection->addFieldToFilter('order_status', 'complete');

Thanks for reading the blog. Please comment if you face any issue.

Searching for an experienced
Magento 2 Company ?
Find out More
. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


Be the first to comment.

Back to Top

Message Sent!

If you have more details or questions, you can reply to the received confirmation email.

Back to Home