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

Drop-down Attribut value on frontend
 
Andreas Burget
Jr. Member
 
Total Posts:  7
Joined:  2010-05-20
 

how do i get the current value of a drop down value from attributes?
If i am using <?php nl2br($this->htmlEscape($_product->getXXX())) ?> i only get a number.
thx and
regards andreas

 
Magento Community Magento Community
Magento Community
Magento Community
 
Ryan Sun _Kuafu
Guru
 
Total Posts:  317
Joined:  2008-11-14
FL
 

the number is the value, I guess you mean current label, try

$product->getAttributeText('attribute_code');
 
Magento Community Magento Community
Magento Community
Magento Community
 
Indies Inc
Sr. Member
 
Avatar
Total Posts:  193
Joined:  2013-09-18
 

Hi,
Magento stores the attributes with their code which was given at creation time. You can access that value using this code. You can use the following code to display your complete drop-down at front end.

<select class="select_but" name="company_type" id="company_type">
        
<?php  
$attribute 
Mage::getModel('eav/config')->getAttribute('catalog_product''[yourattributecode]');
    foreach (
$attribute->getSource()->getAllOptions(truetrue) as $option){ ?>
        
<option value="<?php echo $option['value']; ?>">
                       
<?php echo $option['label']?>
                             
</option>
<?php    } ?>
              
</select>

Hope this will help you.
 

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