Fatal error: Call to a member function toOptionArray() on a non-object

Posted: October 4, 2010 in Magento, Version 1.4.*

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

To solve the above error. Please open the above path file.

if ($e->source_model) {
$sourceModel = Mage::getSingleton((string)$e->source_model);
if ($sourceModel instanceof Varien_Object) {
$sourceModel->setPath($path);
}
$field->setValues($sourceModel->toOptionArray($fieldType == 'multiselect'));
}

Replace above code with below:

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

Thanks,
-Bijal Bhavsar 🙂

Advertisements
Comments
  1. […] Fatal error: Call to a member function toOptionArray() on a non-object October 2010 LikeBe the first to like this post. […]

  2. geetansh says:

    thanks it worked for me and saved precious time….

  3. Tere says:

    thankssssssssssssssssssssssss 😀

  4. Anil says:

    wonderful solution, Thanks

  5. […] Fatal error: Call to a member function toOptionArray() on a non-object October 2010 […]

  6. sam says:

    Thanks for great artical and solve my issue..thanks again…

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s