Lestatu2
Lestatu2

Reputation: 31

Fatal error: Call to a member function toOptionArray() on a non-object in mysite/app/code/core/Mage/Adminhtml/Block/System/Config/Form.php on line 463

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

Answers (6)

Mukesh Chapagain
Mukesh Chapagain

Reputation: 25976

In my case, I solved it with the following steps:-

  1. Disable Compilation (System -> Tools -> Compilation)
  2. Refresh Cache (System -> Cache Management)

Upvotes: 1

Oguzhan Alan
Oguzhan Alan

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

Ben
Ben

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

Raviteja
Raviteja

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

Kandarp B Patel
Kandarp B Patel

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

Anton S
Anton S

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

Related Questions