0

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):

enter image description here

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.

Raphael at Digital Pianism
70.8k37 gold badges192 silver badges357 bronze badges
asked May 9, 2016 at 10:09

1 Answer 1

0

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>
answered May 9, 2016 at 10:12
1
  • 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. Commented May 9, 2016 at 10:22

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.