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 magento.stackexchange.com, 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 community@magento.com.

Magento Forum

Converting an array into attribute values
 
reaktion
Member
 
Total Posts:  48
Joined:  2009-02-16
 

Hi everyone,
On my category page (list.phtml) I am trying to display the values of a multiple select attribute.
The code i’m using to call the attribute is

<?php echo $_product->getAttributeText('key_features_music'?>

but when it shows up on my website, it displays the word “array”

Does anyone know what I need to do to display the correct info from my attribute?

Thanks,
Justin

 
Magento Community Magento Community
Magento Community
Magento Community
 
edmondscommerce
Guru
 
Avatar
Total Posts:  342
Joined:  2008-08-26
 

to see the contents of the array simply call

<?php var_dump($_product->getAttributeText('key_features_music'));

that should give you more of an idea what you need to be doing

 
Magento Community Magento Community
Magento Community
Magento Community
 
reaktion
Member
 
Total Posts:  48
Joined:  2009-02-16
 

Hi Joseph,
thanks for your reply, it has certainly helped.

only things is, it display this in the front end:

Music: array(3) { [0]=> string(2) “DJ” [1]=> string(10) “Live Bands” [2]=> string(12) “Solo Artists” }

Do you know what I need to do to just display the words “DJ”, “Live Bands” and “Solo Artists”?

Thanks,
Justin

 
Magento Community Magento Community
Magento Community
Magento Community
 
clorne
Sr. Member
 
Total Posts:  236
Joined:  2008-01-10
London
 

foreach($_product->getAttributeText(’key_features_music’) as $product)
{
echo $product.’<br />’;
}

 
Magento Community Magento Community
Magento Community
Magento Community
 
reaktion
Member
 
Total Posts:  48
Joined:  2009-02-16
 

Thanks for your reply clorne,

I think I may have missed something though. Here is the code in my list.phtml…

<div class="features-list-table-music">
Music<?php foreach($_product->getAttributeText(’key_features_music’) as $product)
{
echo $product.’<br />’;

?>
</div>

As a result, everything in the front end disappears.

Any suggestions?
Thanks,
Justin

 
Magento Community Magento Community
Magento Community
Magento Community
 
edmondscommerce
Guru
 
Avatar
Total Posts:  342
Joined:  2008-08-26
 

maybe because you are using those dodgy ‘ marks?

 
Magento Community Magento Community
Magento Community
Magento Community
 
reaktion
Member
 
Total Posts:  48
Joined:  2009-02-16
 

what should i replace them with?

I tried “ but after refreshing the page i get an error submission form…
http://premiumnightlife.com.au/report/?id=876570327&s;=sydney_store_view

Cheers

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