1

I am fetching a collection (of user table), that is retrieving correctly. Now I have one more table (ex.- address) that has multiple row related collection table primary key. I want to fetch them all with collection query.

Like - If I print the collection object data via -> $obj->getData() then It is returning data like this

Array=>(
[id] => 1   //====Primary key of user table 
[name] => xyz
[marks] => 85

)

But The way I want is - return data should be like -

Array=>(
[id] => 1   //====Primary key of user table 
[name] => xyz
[marks] => 85
[address] => Array(          //=====Data from related address table========
                1 => (
                    [row_id] => 1
                    [house_no] => 45
                    [id] => 1   //=====Forign Key of user table
                ),
                2 => (
                    [row_id] => 6
                    [house_no] => 45
                    [id]=> 1    //=====Forign Key of user table
                ),
            )

)

Can anyone let me know how I can achieve this. Because I tried with $this->getSelect()->joinLeft() but it works if related table have only one row .

Thanks

  • Can you show your array how do you want? – Sukumar Gorai Jul 26 '18 at 12:54
  • I have modified my question to make it more clear. Plz check again. – Atul Jul 26 '18 at 13:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.