On souhaite afficher sur la vue produit en séparant les attributs dans leurs groupes respectifs
Par exemple, j’ai beaucoup d’attributs pour décrire mon produit. J’ai regroupé ces attributs en sous-groupe dans le back-office.

Sur le front office je ne souhaite pas que mes attributs soient affichés les uns à la suite des autres.
Je veux que les sous-groupes d’attributs soient séparés comme ceci :

Pour cela, il suffit de modifier le fichier mon-theme/template/catalog/product/view/attributes.phtml, avec le code suivant :
<?php
$_helper = $this->helper('catalog/output');
$_product = $this->getProduct();
$attributes_by_groups = array();
$group_names = array();
$group_ids = array();
$attributes = $_product->getAttributes();
$attribute_set = Mage::getModel('eav/entity_attribute_set')->load( $_product->getAttributeSetId() );
$attribute_set_Id = $attribute_set->getAttributeSetId();
$attribute_set_Name = $attribute_set->getAttributeSetName();
foreach ($attributes as $attribute) {
if ($attribute->getIsVisibleOnFront() && $attribute->getIsUserDefined()) {
$group_id = $attribute->getData('attribute_set_info/' . $_product->getAttributeSetId() . '/group_id');
if (!in_array($group_id, $group_ids)) {
array_push($group_ids, $group_id);
}
if ( !isset($group_names[$group_id]) ) {
$group_model = Mage::getModel('eav/entity_attribute_group');
$group_model->load($group_id);
$group_names[$group_id] = $group_model->getAttributeGroupName();
}
}
}
?>
<?php if($_additional = $this->getAdditionalData()): ?>
<?php foreach ($group_ids as $group_id): ?>
<?php $group_name = $group_names[$group_id];
$exclAttr_Arr = array();
foreach ($attributes as $attribute){
if (!(($attribute->getAttributeGroupId()) == $group_id)){
array_push($exclAttr_Arr, ($attribute->getAttributeCode()));
}
} ?>
<?php $_additional = $this->getAdditionalData($exclAttr_Arr);?>
<div>
<h2><?php echo $group_name;?></h2>
<table id="product-attribute-specs-table">
<col width="25%" /><col />
<tbody>
<?php foreach ($_additional as $_data): ?>
<tr>
<th><?php echo $this->htmlEscape($this->__($_data['label'])) ?></th>
<td><?php echo $_helper->productAttribute($_product, $_data['value'], $_data['code']) ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<script type="text/javascript">decorateTable('product-attribute-specs-table')</script>
</div>
<?php endforeach; ?>
<?php endif;?>