Webkul
Services
Technologies Bagisto QloApps
iOS Android SAP BigCommerce Wix
Trusted by
Samsung Intel Toyota Walmart Disney Nokia Nestlé Decathlon
See all customers
Back to Top
DEV

Filtering on joined column in Magento 2

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.

. . .

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