//Set this to whatever you need to.
$allowedGroupIds = array(1,2,3,4);
//Get all groups
$groups = Mage::getModel('eav/entity_attribute_group')
->getResourceCollection()
->setAttributeSetFilter($_product->getAttributeSetId())
->setSortOrder()
->load();
foreach ($groups as $group) {
//Skip the groups you don't need.
if (!in_array($group->getId(), $allowedGroups)) {
continue;
}
echo '<h3>'.$group->getId().' - '.$group->getAttributeGroupName().'</h3>';
//Get attributes from the group
$attributes = Mage::getResourceModel('catalog/product_attribute_collection')
->setAttributeGroupFilter($group->getId())
->addVisibleFilter()
->checkConfigurableProducts()
->load();
if ($attributes->getSize() > 0) {
echo '<ul>';
foreach ($attributes->getItems() as $attribute) {
$attrCode = $attribute->getAttributeCode();
$attrValue = $_product->getData($attrCode);
echo '<li>';
if (!is_array($attrValue)) {
echo $attrCode.' = '.$attrValue;
} else {
//Do something if the attribute value is array.
}
echo '</li>';
}
echo '</ul>';
}
}
HVALA!謝謝Zoki,我想我得到幾乎相同的解決方案。 –
Isidor :)沒問題 – zokibtmkd