After upgrading magento to (from 1.7.) I am now seeing this error in my system.log:

2014-05-26T10:39:56+00:00 ERR (3): Warning: Invalid argument supplied for foreach() in app/code/core/Mage/Eav/Model/Entity/Collection/Abstract.php on line 776

Line 776 of Abstract.php:

foreach ($fields as $alias=>$field) {
    if (isset($this->_joinFields[$alias])) {
        throw Mage::exception(
            Mage::helper('eav')->__('A joint field with this alias (%s) is already declared', $alias)
    $this->_joinFields[$alias] = array(
        'table' => $tableAlias,
        'field' => $field,

Anybody else seeing this error and is it a bad one or can it be ignored?

  • can you provide more context? What code calls that method? What page? Do you have any extensions that might generate this?
    – Marius
    Commented May 26, 2014 at 10:54
  • It is part of a public function called "joinTable", however I can't find any template that calls this function so I have no idea how to track this down... The error usually pops up every other minute, sometimes every other second.
    – loeffel
    Commented May 26, 2014 at 13:31

2 Answers 2


I had the problem too and your comment hinted me to the right spot.

As you said the error comes from the public function joinTable() in app/code/core/Mage/Eav/Model/Entity/Collection/Abstract.php.

Unlike you I have used joinTable() in a Module of mine.

The head of that function says the following

 * @param string|array $table
 * @param string $bind
 * @param string|array $fields
 * @param null|array $cond
 * @param string $joinType
 * @return Mage_Eav_Model_Entity_Collection_Abstract
public function joinTable($table, $bind, $fields = null, $cond = null, $joinType = 'inner')

Problem here is that $fields should not be of type string as said in the @param because it is used in a foreach loop.

I modified my call of joinTable() to not give a string, but an array with a string. No log entries so far.

My guess for you would be that some module uses joinTable and passes just a string for $fields. Are you able to debug into your code? That way you would have the stacktrace and could determine which modules fault that was.


I've looked further into it to anser your last questions:

"is it a bad one"

No. The join will still work, because later on, deep in call structure reachable from line 817 of Abstract.php there is a check if $fields (until then called $cols) is an array (/lib/Varien/Db/Select.php line 411) and if not will be converted into one for further processing (this is missing in Abstract.php).

"can it be ignored"

I'd say yes. It crams your log, but not disabling your project (at this point).


This code resolved your problem,

Add before -> foreach ($fields as $alias=>$field)

if (!is_array($fields)){

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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