3.7 (73.33%) 3 votes

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!

Your Magento website needs a powerful Magento ERP for stock control.

DON'T MISS THE CHANCE!

magento erp

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

Comments

  1. Light

    Hey there! Quick question that’s completely off topic.
    Do you know how to make your site mobile friendly?
    My website looks weird when viewing from my iphone4. I’m
    trying to find a theme or plugin that might be able to correct this issue.
    If you have any recommendations, please share. Many thanks!

Leave a Reply

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