0

I have an attribute called 'made_to_order' and it has a dropdown select (in the backend of Magento) with two outcomes 'yes' or 'no'. At the moment I'm just echoing the yes or no on the frontend. However, ideally I'd like to show different html dependent on the attribute value. For example, if 'yes' then green color font, if 'no' then red color font.

Can anyone please help with the code for this? My current code is:

 <p style="font-size: 1.1em;line-height:1.2em;"><?php echo $_product->getAttributeText('made_to_order') ?></p>

Thank you very much

1

Try

<?php if($_product->getAttributeText('made_to_order') == $this->__('yes')): ?>
      <p class="made_to_order_yes"><?php echo $_product->getAttributeText('made_to_order') ?></p>
<?php else; ?>
     <p class="made_to_order_no"><?php echo $_product->getAttributeText('made_to_order') ?></p>
<?php endif; ?>
2
0

I'm using Magento 1.9 and this code works for me

<?php if($_product->getData(" --attribute name-- ")==1)
{
}
else
{
}
?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.