How to display Attribute Group Name on Product page?

Ok, I googled and found nice solutions. And just shared it here.

There are two solutions -

1.  Here is magento extension
2. Other solution was in german and here nice translation from Theophilos. I just copied Theophilos’s translation here -

Ok, I found an answer and I hope it will be useful to others in search for the same thing. First, I’m using Magento 1.5.0. Second, I found the answer in German here, with an extension already created, but the installation failed. So, I added /app/code/local/Mage/Catalog/Block/Product/View/Attributesgroups.php with the following code:

<?php class Mage_Catalog_Block_Product_View_Attributesgroups extends Mage_Core_Block_Template {     protected $_product = null;     function getProduct()     {         if (!$this->_product) {             $this->_product = Mage::registry('product');         }         return $this->_product;     }     public function getAdditionalData(array $excludeAttr = array())     {         $data = array();         $product = $this->getProduct();         $attributes = $product->getAttributes();         foreach ($attributes as $attribute) {             if ($attribute->getIsVisibleOnFront() && !in_array($attribute->getAttributeCode(), $excludeAttr)) {                 $value = $attribute->getFrontend()->getValue($product);                 // TODO this is temporary skipping eco taxes                 if (is_string($value)) {                     if (strlen($value) && $product->hasData($attribute->getAttributeCode())) {                         if ($attribute->getFrontendInput() == 'price') {                             $value = Mage::app()->getStore()->convertPrice($value,true);                         } elseif (!$attribute->getIsHtmlAllowedOnFront()) {                             $value = $this->htmlEscape($value);                         }                         $group = 0;                         if( $tmp = $attribute->getData('attribute_group_id') ) {                             $group = $tmp;                         }                         $data[$group]['items'][ $attribute->getAttributeCode()] = array(                            'label' => $attribute->getFrontend()->getLabel(),                            'value' => $value,                            'code'  => $attribute->getAttributeCode()                         );                         $data[$group]['attrid'] = $attribute->getId();                     }                 }             }         }         // Noch Titel lesen         foreach( $data AS $groupId => &$group ) {             $groupModel = Mage::getModel('eav/entity_attribute_group')->load( $groupId );             $group['title'] = $groupModel->getAttributeGroupName();         }         return $data;     } } 

Then, I created the /app/design/frontend/default/YOUR_TEMPLATE/template/catalog/product/view/attributesgroups.phtml file with the following content:

<?php     $_helper = $this->helper('catalog/output');     $_product = $this->getProduct() ?> <?php if($_additionalgroup = $this->getAdditionalData()): ?> <div class="box-collateral box-additional">     <h2><?php echo $this->__('Additional Information') ?></h2>     <?php $i=0; foreach ($_additionalgroup as $_additional): $i++; ?>         <h3><?php echo $this->__( $_additional['title'] )?></h3>         <table id="product-attribute-specs-table-<?php echo $i?>">             <col width="25%" />             <col />             <tbody>             <?php foreach ($_additional['items'] as $_data): ?>                 <tr>                     <th class="label"><?php echo $this->htmlEscape($this->__($_data['label'])) ?></th>                     <td class="data"><?php echo $_helper->productAttribute($_product, $_data['value'], $_data['code']) ?></td>                 </tr>             <?php endforeach; ?>             </tbody>         </table>         <script type="text/javascript">decorateTable('product-attribute-specs-table-<?php echo $i?>')</script>     <?php endforeach; ?> </div> <?php endif;?> 

Last step was to modify /app/design/frontend/default/YOUR_TEMPLATE/layout/catalog.xmlin line 223, and replaced

 <block type="catalog/product_view_attributes" name="product.attributes" as="additional" template="catalog/product/view/attributes.phtml">

with

 <block type="catalog/product_view_attributesgroups" name="product.attributes" as="additional" template="catalog/product/view/attributesgroups.phtml"> 

I repeat, this answer does NOT belong to me, I just translated what I found. Many thanks to the beautiful people who ended my three days of search with a clean and simple answer: WebGuys.DE Also, thanks to @rpSetzer who cared to help!

Add a comment »2 comments to this article

  1. Hey Otabek,

    many thanks for your great feedback. I have added your post as an english translation and the topic of my article :) take a look at http://www.webguys.de/magento/attributes-als-attribute-set-im-webshop-darstellen/

    nice greetings from germany

    Tobi

    Reply

    • Thanks, Tobi! It was so helpful from your side :)

      Reply

*


*

Copyright © All Rights Reserved · Green Hope Theme by Sivan & schiy · Proudly powered by WordPress