Reputation: 31
Hello I'm using magento 1.7.0.2 and if I try to install an extension (personal bar) when i go to configuration it gives me the following error:
Fatal error: Call to a member function toOptionArray() on a non-object in app/code/core/Mage/Adminhtml/Block/System/Config/Form.php on line 463
line 463:$optionArray = $sourceModel->toOptionArray($fieldType == 'multiselect');
Can you heelp me?
$sourceModel = Mage::getSingleton($factoryName);
if ($sourceModel instanceof Varien_Object) {
$sourceModel->setPath($path);
}
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);
}
Upvotes: 3
Views: 9227
Reputation: 25976
In my case, I solved it with the following steps:-
System -> Tools -> Compilation
) System -> Cache Management
)Upvotes: 1
Reputation: 1
I had the same problem with a theme, because a menu for the backend was not named uniquely. In my case, "Magento Theme Bearstore" had the menu entry "themeoptions", but a menu called "themeoptions" was already existing in the m2e module for German Magento!
So do check out which factoryname is conflicted. In my case, I renamed all "themeoptions" (also module names etc.) to "bearstoreoptions" (be careful in match case).
Upvotes: 0
Reputation: 61
Go to app\code\core\Mage\Adminhtml\Block\System\Config\Form.php
find the following on line 463
$optionArray = $sourceModel->toOptionArray($fieldType == ‘multiselect’);
and replace it with:
if(is_object($sourceModel)){
$optionArray = $sourceModel->toOptionArray($fieldType == ‘multiselect’);
} else {
Mage::log($e->source_model);
}
Upvotes: 6
Reputation: 41
In system.xml configuration file
select/multiselect
modulename/namespace_module_model_somemodelname
.
Then create namespace_module_model_somemodulename file..
write this toOptionArray() method in your own model (i.e) something like this..
Eg:
public function toOptionArray()
{
return array(
array('value' => 1, 'label'=>Mage::helper('newmodule')->('Yes')),
array('value' => 0, 'label'=>Mage::helper('newmodule')->('No')),
);
}
suppose modulename->adminhtml/Mage_Adminhtml_Model_System_Config create this function.
Then you shouldn't get the error...
Upvotes: 1
Reputation: 1061
Its possible when source model now define for some attribute. Please check eav_attribute Table source_model field. some entry may be wrong or missing.
Upvotes: 4
Reputation: 12750
Check your file permissions and if extension is installed properly and all files are on the server and if the backend_model for the config field that gives this error exists
Upvotes: 0