Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email

Magento Forum

set value of attribute of type select
Jr. Member
Total Posts:  14
Joined:  2008-09-01

I wonder how can i change value of attribute that is set as select.

Now i do it in a way that i think is extremely lame but works, anyway i’m sure there must be far easier way to do it, but i didn’t find it…

I hava attribute “seller_confirmation” and i don’t know how to get to its options easily!

I know i could use setSeller_confirmation(285). But what if i don’t know this code and want to set it to value “rejected” and this text value is all i know?

$attrs as $attr{
if ($attr->getAttributeCode()=='seller_confirmation'{


$collection as $option{
Magento Community Magento Community
Magento Community
Magento Community
Jr. Member
Total Posts:  20
Joined:  2008-11-17

Hi, jakilcz

Ok, this is something seeming not easy at all, and pretty difficult to get completely at first… I mean that was for me.

Here is the magical class for that : Mage_Eav_Model_Entity_Attribute_Source_Table

Once you have the attribute object, you have to get its source, and then its options. Like this :

$seller $attrs['seller_confirmation'];
$options $seller->getSource()->getAllOptions();
then loop through $options to get the id with the text value.

You have to make sure $seller is a completely loaded attribute magento object (a select attribute, of course)

inversely, you could use

$option $seller->getSource()->getOptionText($id);
to get the text of a known id value.

That should do it.
PM me if you have problems with this.

Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top