How to order or filter grid backend Magento with collection which is joined from multiple table in Magento 2.

In magento 2, some time you join some tables and display them into a grid backend Magento but when you sort or filter them, you found an “field not found” error.

Example, I have 2 tables:

Talbe 1 has name “customer” with fields “name”, “gender”, “age”

Table 2 has name “address” with fields “address”, “city”, “country”

And you join table 2 into table 1 collection and display them into a grid backend magento.

If you want to filter or sort the fields “address”, “city”, “country”, you should override “addFieldToFilter”, “sortOrder” and “addOrder” functions

Hope it helpful for you.

The steps I mention above is the shortest process for you to order or filter grid backend Magento with collection which is joined from multiple table in Magento 2 . With this guide, you can manage the order or filter grid backend Magento with collection which is joined from multiple table in Magento 2 easily. Every store has an order or filter grid backend Magento with collection which is joined from multiple table in Magento 2 with many attributes.

Thank you for reading this post and see you in other posts from Magestore!


Ready to foster your knowledge

with MAGENTO 2 BASIC GUIDE

magento 2 basic guide series


How to Use all Commands in Magento 2 CLI (Part 9)
How to Override a Template File in Magento 2

Leave a Reply

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