php - Magento load product attributes by group? -
is there way foreach loop , loop through product attributes in attribute group in magento? please check screenshot. example, wanna loop through values in attributes of design group.
thanks
no there no built in function return array of product attributes organized group. 1 of missing functionalities. need create in helper or block class.
[edit]
it looks wrong. there method return attributes given group. in mage_catalog_model_product::getattributes()
. first argument there group id. can this:
$groupid = mage::getmodel('eav/entity_attribute_group')->getcollection() ->addfieldtofilter('attribute_set_id', array('eq' => $_product->getattributesetid())) ->addfieldtofilter('attribute_group_name', array('eq' => 'general')) ->getfirstitem()->getid(); foreach($_product->getattributes($groupid) $attribute) { //this return text value multiselect $attributeval = $attribute->getfrontend()->getvalue($_product); //or need handle retriving select , multiselect labels $attributeval = $_product->getdata($attribute->getcode()); }
this make easier attributes group think still require own helper or, better, own block piece of code in phtml file not best practice.
Comments
Post a Comment