Im working on a sports e shop and some shoes belong to specific techs which i would like to be shown as images

like this:

enter image description here

I thought of creating a multi select attribute named techs and put values as shown below and create for each option a seperate cms block so that i would call many of these simultanously


<?php /* @var $this Mage_Catalog_Block_Product_View_Abstract */?>
<?php $_product = $this->getProduct() ?>

<?php echo $this->getChildHtml('product_type_data_extra') ?>
<?php echo $this->getPriceHtml($_product) ?>
<?php if ($this->displayProductStockStatus()): ?>
    <?php if ($_product->isAvailable()): ?>
            <p class="availability in-stock"><?php echo $this->__('Availability:') ?> <span><?php echo $this->__('In stock') ?></span></p>
    <?php else: ?>
            <p class="availability out-of-stock"><?php echo $this->__('Availability:') ?> <span><?php echo $this->__('Out of stock') ?></span></p>
    <?php endif; ?>
<?php endif; ?>
<!--  Step 1  We need to add this to be able to get the attribute values -->
    $_helper = $this->helper('catalog/output');
    $_product = $this->getProduct()
<!--  Step 2  Allow for techs attribute to display different images based on value of attribute -->
<?php if ($_product->getAttributeText('tech') == "Pulsor"): ?>
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('tech_pulsor')->toHtml() ?>

<?php elseif ($_product->getAttributeText('tech') == "Flexo"): ?>
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('tech_flexo')->toHtml() ?>
<?php endif; ?>

However when i put 2 cms nothing is shown if i put one its ok

2 Answers 2


You need to use it as an array

   $techTypes = explode(",",$_product->getResource() ->getAttribute('tech')->getFrontend() ->getValue($_product));
foreach($techTypes as $key => $value){ 
    if ($_product->getAttributeText('tech') == "Pulsor"):
    echo $this->getLayout()->createBlock('cms/block')->setBlockId('tech_pulsor')->toHtml();

    elseif ($_product->getAttributeText('tech') == "Flexo"):
    echo $this->getLayout()->createBlock('cms/block')->setBlockId('tech_flexo')->toHtml();


I managed to do this without the use of cms blocks

<!-- Display Product Tech Images -->

<div class="techs">
<div class="techs-title">
   $multiSelectArray = $this->getProduct ()->getAttributeText('tech');
   $lastItem = end ($multiSelectArray);

   foreach ($multiSelectArray as $multiSelectItem) :?>

   <a tabindex="0" role="button" title="" data-toggle="popover" data-trigger="hover" data-placement="top" data-original-title="<? echo $multiSelectItem; ?>">
   <img src="/media/wysiwyg/techs/<?php echo $multiSelectItem ?>.jpg"></img>
   <p class="tech-name"><? echo $multiSelectItem; ?></p>
   <div class="hidden popover-content">


   <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script type="text/javascript">

   <?php endforeach;?>



Your Answer

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

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