Getting Attribute List in Theme file

Permalink
I have a custom attribute that is a Select list that allows the user to choose multiple values. I know how to get the Attribute value using the $c-getCollectionAttributeValue() but it returns as an Object. How can I get these values as an array?

Thanks.

ideasponge
 
jaredquinn replied on at Permalink Best Answer Reply
jaredquinn
Calling getCollectionAttributeValue() on a Select List returns you a SelectAttributeTypeOptionList object.

The SelectAttributeTypeOptionList implements array functionality within itself, so you can just use it like you would an array.

If you iterate through it, each element will be returned as a SelectAttributeTypeOption object. If you use this object as a string, you'll get the value of the element.

foreach($c->getCollectionAttributeValue('test2') as $opt) {
   echo '<li>' . $opt . '<li/>';
}
ideasponge replied on at Permalink Reply
ideasponge
Awesome thanks. You the man!