0

I've been trying to join 2 tables with the existing collection of Customers (customer_entity).

I've added like below.

$items->getSelect()->join('customer_entity_text as second', 'main_table.entity_id = second.entity_id');

Above is working fine, But if i add one more table to join with this is that is customer_entity_varchar than its not working.

Below is my code to join 2 tables.

$items->getSelect()->join('customer_entity_text as second', 
'main_table.entity_id = second.entity_id')
->join('customer_entity_varchar as third', 'main_table.entity_id = third.entity_id');

Any guide ?

*

3
  • 1
    It should work fine for more than 2 tables also. Can you share your code for 3 tables? May 25, 2018 at 13:34
  • just a question: why do you want to join and not simple addAttributeToSelect()? May 25, 2018 at 21:49
  • @MohitKumarArora, Check i've updated question.
    – anonymous
    May 26, 2018 at 4:14

1 Answer 1

2

Try to do with the addition of joins , example : (substitute your columns)

$items->getSelect()->join(
       ['table1join'=>$collection->getTable('customer_entity_text')],
                    'e.entity_id = table1join.product_id',
                    ['column1'=>'table1join.column1','column2'=>'table1join.column2']);
$items->getSelect()->join(
                    ['table1join'=>$collection->getTable('main_table')],
                    'e.entity_id = table1join.product_id',
                    ['table2column1'=>'table1join.column1','table2column1'=>'table1join.column2']);
$items->getSelect()->join(
                ['table2join'=>$collection->getTable('customer_entity_varchar')],
                'e.entity_id = table2join.product_id',
                ['table3column1'=>'table2join.column1','table3column1'=>'table2join.column2']);

I hope my answer brings you closer to the solution.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.