0

当我尝试访问系统 > 配置 > 高级 > 系统时出现此错误

致命错误:在第 421 行的 /home/server/public_html/store/app/code/core/Mage/Adminhtml/Block/System/Config/Form.php 中的非对象上调用成员函数 toOptionArray()

我找到了这个答案:致命错误:调用成员函数 toOptionArray()

但是,需要根据该答案替换的代码与该文件(Form.php)中的代码不同:

         if ($method) {
                if ($fieldType == 'multiselect') {
                    $optionArray = $sourceModel->$method();
                } else {
                    $optionArray = array();
                    foreach ($sourceModel->$method() as $value => $label) {
                        $optionArray[] = array('label' => $label, 'value' => $value);
                    }
                }
            } else {
                $optionArray = $sourceModel->toOptionArray($fieldType == 'multiselect');
            }
            $field->setValues($optionArray);
        }
    }
}
return $this;

有任何想法吗?谢谢!

4

2 回答 2

1

If you look in Form.php from line 398 to 425 you have almost the same code. The code from your answer isn't a fix, is just a way to help you determine your real problem, so you can use that code:

if(is_object($sourceModel)){
    $field->setValues($sourceModel->toOptionArray($fieldType == 'multiselect'));
} else {
    Mage::log($e->source_model);
}

And then you would have to look into the Magento log file to see what happened. Also you can try to log debug_print_backtrace(); Probably your problem comes from a badly written extension.

于 2012-06-05T13:24:44.573 回答
0

以下步骤应该可以解决错误:-

  1. 禁用编译( System -> Tools -> Compilation)
  2. 刷新缓存( System -> Cache Management)
于 2016-06-09T11:54:47.283 回答