8

In the file app/code/core/Mage/Eav/Model/Entity/Collection/Abstract.php, there is a function named joinField and there is another joinTable.

If fields are actually columns in the flat tables, what does it mean to join them? An in what circumstance I should use joinTable instead? Can they both be used interchangeably?

5

Both methods are almost identical, the difference is that joinField() only selects a single column from the joined table, while you can specify an array of columns in joinTable`.

So you can always use joinTable instead of joinField. The example

 joinField('country_name', 'directory/country_name', 'name', 'country_id=shipping_country', "{{table}}.language_code='en'", 'left')

is the same as

 joinTable('directory/country_name', 'country_id=shipping_country', ['country_name' => 'name'], "{{table}}.language_code='en'", 'left')

But joinField() should not be used if you need more than one column of the joined table.

|improve this answer|||||

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.