views:

53

answers:

2

I've been grabbing attribute options from Magento like so:

<?php

if ($attribute->usesSource()) {
    $options = $attribute->getSource()->getAllOptions(false);
}

?>

It's been working fine until I tried to get the options for the built in 'color' attribute -- I got the following error:

PHP Fatal error:  Call to a member function setAttribute() on a non-object in app/code/core/Mage/Eav/Model/Entity/Attribute/Abstract.php on line 374

It would appear that the getSource() call fails and causes this error. Does anyone know why this happens and how I can get color options out?

Thanks!

A: 

Sorry for an incomplete answer, but take a look at the database, specifically in the "backend_model" column. I seem to remember having this same problem until I set this field to match some of the system fields in this respect.

Hope that helps!

Thanks, Joe

Joseph Mastey
A: 

Maybe not an exact answer but what version of Magento are you running?

I had exactly the same issue as yourself just today. I discovered that i was running 1.4.1.0. My code worked prefect on an install running on 1.4.1.1 - as a last resort I upgraded to 1.4.1.1 and it started working again.

If this doesnt help then maybe, as Joseph pointed out, that there is something wrong in the database.

Drew