Get attributes by attribute group Magento

magento

Solution

  $setId = $_product->getAttributeSetId(); // Attribute set Id
        $groups = Mage::getModel('eav/entity_attribute_group')
            ->getResourceCollection()
            ->setAttributeSetFilter($setId)
            ->setSortOrder()
            ->load();

        $attributeCodes = array();
        foreach ($groups as $group) {
            if($group->getAttributeGroupName() == 'Somename'){ // set name
            //$groupName          = $group->getAttributeGroupName();
            //$groupId            = $group->getAttributeGroupId();

            $attributes = Mage::getResourceModel('catalog/product_attribute_collection')
                ->setAttributeGroupFilter($group->getId())
                ->addVisibleFilter()
                ->checkConfigurableProducts()
                ->load();
                if ($attributes->getSize() > 0) {
                    foreach ($attributes->getItems() as $attribute) {
                        /* @var $child Mage_Eav_Model_Entity_Attribute */
                        $attributeCodes[] = $attribute->getAttributeCode();                     
                    }
                } 
          }
        }
        print_r($attributeCodes);

Problem

I have product: ``` <?php $_helper = $this->helper('catalog/output'); ?> <?php $_product = $this->getProduct(); ?> ``` I have name (not ID) of attribute group. I need to list all attributes names and values in this attribute group (does not matter on attribute set). How can i get attributes and values from attribute group, if i know only product and a attribute group name?

Original source