Advertisement
Guest User

magento attribute images on product view

a guest
Sep 7th, 2012
327
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 8.28 KB | None | 0 0
  1. <?php                                                                                                                                                                                                                                    
  2. $_product    = $this->getProduct();                                                                                                                                                                                                      
  3. $_attributes = Mage::helper('core')->decorateArray($this->getAllowAttributes());                                                                                                                                                        
  4. ?>                                                                                                                                                                                                                                      
  5. <?php if ($_product->isSaleable() && count($_attributes)):?>                                                                                                                                                                            
  6.     <dl>                                                                                                                                                                                                                                
  7.     <?php foreach($_attributes as $_attribute): ?>                                                                                                                                                                                      
  8.         <dt><label class="required"><em>*</em><?php echo $_attribute->getLabel() ?></label></dt>                                                                                                                                        
  9.         <dd<?php if ($_attribute->decoratedIsLast){?> class="last"<?php }?>>                                                                                                                                                            
  10.         <?php if ($_attribute->getLabel() == "Color") { ?>-                                                                                                                                                                              
  11.             <div class="input-box">                                                                                                                                                                                                      
  12.                 <input name="super_attribute[<?php echo $_attribute->getAttributeId() ?>]" id="attribute<?php echo $_attribute->getAttributeId() ?>" type="hidden" value="" />                                                          
  13.                 <?php-                                                                                                                                                                                                                  
  14.                     $attribute = $_product->getResource()->getAttribute('color'); //load the configurable attribute here which is the color                                                                                              
  15.                     $frontend = $attribute->getFrontend();                                                                                                                                                                              
  16.                     $selectOptions = $frontend->getSelectOptions();               //get the frontend labels and values of this attribute                                                                                                
  17.                     foreach($selectOptions as $color_prop){                                                                                                                                                                              
  18.                 ?>                                                                                                                                                                                                                      
  19.                     <img onClick="document.getElementById('attribute<?php echo $_attribute->getAttributeId() ?>').value = this.id;" id="<?php echo $color_prop['value'] ?>" src="<?php echo Mage::helper('attributeoptionimage')->getAttributeOptionImage($color_prop['value']) ?>" width="30" height="30">                                                                                                                                                                      
  20.                 <?php } ?>                                                                                                                                                                                                              
  21.                                                                                                                                                                                                                                          
  22.               </div>                                                                                                                                                                                                                    
  23.         <?php }else{ ?>                                                                                                                                                                                                                  
  24.             <div class="input-box">                                                                                                                                                                                                      
  25.                 <select name="super_attribute[<?php echo $_attribute->getAttributeId() ?>]" id="attribute<?php echo $_attribute->getAttributeId() ?>" class="required-entry super-attribute-select">                                    
  26.                     <option><?php echo $this->__('Choose an Option...') ?></option>                                                                                                                                                      
  27.                   </select>                                                                                                                                                                                                              
  28.               </div>                                                                                                                                                                                                                    
  29.         <?php } ?>                                                                                                                                                                                                                      
  30.         </dd>                                                                                                                                                                                                                            
  31.     <?php endforeach; ?>                                                                                                                                                                                                                
  32.     </dl>                                                                                                                                                                                                                                
  33.     <script type="text/javascript">                                                                                                                                                                                                      
  34.         var spConfig = new Product.Config(<?php echo $this->getJsonConfig() ?>);                                                                                                                                                        
  35.     </script>                                                                                                                                                                                                                            
  36. <?php endif;?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement