Magento show Attribute on catalog category page

If we want to display attribute on (Color Attribute, Size Attribute, etc ) catalog list page . Than follow below step.

Go to folder app/design/frontend/default/default/template/catalog/product/list.phtml and edit the list.phtml file.
put this code on inside foreach loop where you want to display configurable product attribute



<?php if ($_product->isSaleable()):                                     
         $cProduct = Mage::getModel('catalog/product')->load($_product->getId());
           if ($cProduct->getData('type_id') == "configurable") {
               $config = $cProduct->getTypeInstance(true);
               $_simple_ids='';
               $_simple_ids = $cProduct->getTypeInstance()->getUsedProductIds();
               foreach ($_simple_ids as $_simple_id){
                   $_simpleproduct = Mage::getModel('catalog/product')->load($_simple_id);
                   if($_simpleproduct->getData('is_salable') && $_simpleproduct->isAvailable()){
                       $_final_simple_products[] = $_simpleproduct->getData('size');
                    }
                }
                                         
             foreach ($config->getConfigurableAttributesAsArray($cProduct) as $attributes)
			// check here which Attribute you want to display on category list page
               if (strtolower($attributes["label"]) == 'size' or strtolower($attributes["label"])=='sizes') {                                                
              	echo "<span>" . $attributes["label"] . "</span>";
			$_attrcount = 0;
                  echo "<span>";
                   foreach ($attributes["values"] as $values) {
                       if(in_array($values["value_index"], $_final_simple_products)){
                         if ($_attrcount > 0) {
                                echo ",";
                            }
                               echo $values["label"];
                          $_attrcount++;
                         }
                      }
                      echo "</span>";
                                }
                            }
                            unset($_final_simple_products);
                        }
                    endif; ?>  

Leave a Reply