Can anyone describe how to use joinField() method of collection (Magento\Eav\Model\Entity\Collection\AbstractCollection).

I actually don't know what means each argument:

public function joinField($alias, $table, $field, $bind, $cond = null, $joinType = 'inner')

Great Thanks!


The function describes itself if you check comments added before the function.

 * Join regular table field and use an attribute as fk
 * Examples:
 * ('country_name', 'directory_country_name', 'name', 'country_id=shipping_country',
 *      "{{table}}.language_code='en'", 'left')
 * @param string $alias 'country_name'
 * @param string $table 'directory_country_name'
 * @param string $field 'name'
 * @param string $bind 'PK(country_id)=FK(shipping_country_id)'
 * @param string|array $cond "{{table}}.language_code='en'" OR array('language_code'=>'en')
 * @param string $joinType 'left'
 * @return $this
 * @throws LocalizedException

First Argument is $alias which allows to add the alias for the table name we want to join.
Second argument is $table which is actual table name in the database.
Third argument is $field, the field which we want to join
Fourth argument is $bind where you define the ON condition of your sql query
Fifth argument is $cond which allows to add where conditions
Last argument is $joinType which defines your table join type. left, right, inner

  • I've updated question – Kyrylo Romantsov Sep 15 '17 at 9:29
  • @KyryloRomantsov, please check updated answer – Yogesh Trivedi Sep 15 '17 at 10:15
  • That error still occure – Kyrylo Romantsov Sep 15 '17 at 10:18
  • @KyryloRomantsov, I had checked the table and had updated the column names as required. please check now – Yogesh Trivedi Sep 15 '17 at 10:24
  • it doesn't work, I can't understand how to make fk – Kyrylo Romantsov Sep 18 '17 at 8:15

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.