0

I have a question about the attributes and labels. I need to label and value appear in the list of products , only those that relate to the product . I did the following in list.phtml. I entered the code:

<?php echo $_product->getResource()->getAttribute('obiem_baka')->getStoreLabel(); ?>
<?php echo $_product->getAttributeText('obiem_baka');?>

The problem is that the label is displayed is always displayed , even if no value . I need that to label displayed only when there is a value .

Thank you so much.

P.S. I apologize for the error , does not speak English .

1

Try this:

<?php $attributeText = $_product->getAttributeText('obiem_baka');?>
<?php if($attributeText):?>
<?php echo $_product->getResource()->getAttribute('obiem_baka')->getStoreLabel(); ?>
<?php echo $attributeText;?>
<?php endif;?>

OR

<?php if($_product->getAttributeText('obiem_baka')):?>
<?php echo $_product->getResource()->getAttribute('obiem_baka')->getStoreLabel(); ?>
<?php echo $_product->getAttributeText('obiem_baka');?>
<?php endif;?>

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.