2

Create Dropdown attribute , if dropdown value is "yes" than image(any image) will display in products page and if dropdown value is "no" than image will not display.

1
  • First You Get Dropdown Attribute Value Yes and No. And set condition if value Yes than display image else should be blank... Check Below Link to Get Dropdown Value.magentocustom.blogspot.in/2011/05/…
    – Nikul
    Commented Jul 8, 2016 at 11:06

2 Answers 2

0
  • Create a new attribute under Store -> Attributes
  • link the newly created attribute to the Attribute Set (Store-Menu)
  • in your phtml, get value of Attribute with $_item->getData('your_attribute_code'). Example below.

    <?php if($_item->getData('my_attribute') == 1): //do something endif; ?>

1
  • Downvoter: explain what is wrong with this solution and I'll try to edit it.
    – Max
    Commented Nov 4, 2016 at 10:11
0

please follow the my code to getting exact output..

<?php
$productId = 1;
$product = Mage::getModel('catalog/product')->setStoreId(Mage::app()->getStore()->getId())->load($productId);
$selectedvalue  = $product->getAttributeText('paypal');

$atributeCode = 'paypal';
$attribute = Mage::getModel('eav/config')->getAttribute('catalog_product',$atributeCode);
$options = $attribute->getSource()->getAllOptions();

        foreach($options as $key => $value){

            if(in_array($selectedvalue,$value)){
                if($selectedvalue=='yes')
                {
                echo "<pre>";
               // print_r($value); //get Product's selected attribute options Values
                //echo(implode($value));
                echo "</pre>";  
                //echo "<div id='some'><img src='image.jpg'></div>";
               echo "<img src='https://www.paypalobjects.com/webstatic/mktg/logo/bdg_now_accepting_pp_2line_w.png' border='0' alt='Now accepting PayPal'>";
                continue;
                }
            }


        }
?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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