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.
2 Answers
- 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; ?>
-
Downvoter: explain what is wrong with this solution and I'll try to edit it.– MaxCommented Nov 4, 2016 at 10:11
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;
}
}
}
?>