In magento 1.9.2.4, I need to map the options of 'multiple select' attribute with the image to display at frontend.
I have created an multiple select attribute with options like below (item1,item2, item3):
And I have put the image inside media/img like below:
enter image description here
And finally entered my code in my my app/design/frontend/<my_package>/<my_theme>/template/catalog/product/list.phtml
The code is:
<div class="feature">
<?php
$Feature = explode(",",$_product->getResource()
->getAttribute('feature')->getFrontend()
->getValue($_product));
foreach($Feature as $key => $value){
<img src="/media/img/<?php echo $multiSelectItem ?>"></img>
echo $value;
}
?>
</div>
but the image is not displayed. Instead error like Parse error: syntax error, unexpected '<' in <path to /list.phtml> is getting displayed.
someone please help me to resolve this issue.
1 Answer 1
Well your code is mixing PHP and HTML without closing the PHP tag.
You should fix your code like this:
<div class="feature">
<?php
$Feature = explode(",",$_product->getResource()
->getAttribute('feature')->getFrontend()
->getValue($_product));
foreach($Feature as $key => $value): ?>
<img src="/media/img/<?php echo $multiSelectItem ?>"></img>
<?php echo $value; ?>
<?php endforeach; ?>
</div>
-
Images are getting displayed. but it is broken. Also the option names are also displayed beneath. I don't want the option name to get displayed below the image. Please kindly suggest a solution.Ramya– Ramya2016年05月09日 10:22:17 +00:00Commented May 9, 2016 at 10:22