I need to get all the attribute group id associated with the product.


$product_coll = $block->getProduct($product_id);
$pattr = $product_coll->getAttributeSetId();
$attrCodes = $block->getProductAttrData($pattr);
foreach($attrCodes as $attrCode)
    echo $attrCode->getDefaultFrontendLabel().'<br>';
    $code = $attrCode->getAttributeCode().'<br>';
    echo $product_coll->getData($code).'<br>';
    echo $block->getProductAttrValue($product_id, $code).'<br>';


I want to filter the attribute with it's group or group name "product details". Any help appreciated.

1 Answer 1


Block function

public function getAttributeGroupId($attributeSetId)
         $obj = \Magento\Framework\App\ObjectManager::getInstance();

        /** @var \Magento\Catalog\Model\Config $config */
        $config= $obj->get('Magento\Catalog\Model\Config');

        return $attributeGroupId = $config->getAttributeGroupId($attributeSetId, 'Product Details');


In html file

$group_id = $block->getAttributeGroupId('attribute_set_id');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.