Retrieve EAV Attribute Group Details by the attribute_group_id will return the valuable information, attribute set id, group name, sort order, default id, attribute group code and tab group code
You required id to fetch details of the product attribute group,
Just Create a Model file and fetch the details by given code snippet,
<?php namespace Jesadiya\AttributeGroup\Model; use Exception; use Magento\Eav\Api\Data\AttributeGroupInterface; use Magento\Catalog\Api\ProductAttributeGroupRepositoryInterface; class ProductAttributeGroup { /** * @var ProductAttributeGroupRepositoryInterface */ private $productAttributeGroup; public function __construct( ProductAttributeGroupRepositoryInterface $productAttributeGroup ) { $this->productAttributeGroup = $productAttributeGroup; } /** * Product Attribute Group By Id * * @return AttributeGroupInterface */ public function getAttributeGroupById() { $groupId = 1; //DYNAMIC_GROUP_ID try { $productAttributeGroup = $this->productAttributeGroup->get($groupId); } catch (Exception $exception) { throw new Exception($exception->getMessage()); } return $productAttributeGroup; } }
Call from the template or any PHP class,
$attributeDetails = $this->getAttributeGroupById();
Output:
Magento\Eav\Api\Data\AttributeGroupInterface
array (size=7) 'attribute_group_id' => string '1' (length=1) 'attribute_set_id' => string '1' (length=1) 'attribute_group_name' => string 'General' (length=7) 'sort_order' => string '1' (length=1) 'default_id' => string '1' (length=1) 'attribute_group_code' => string 'general' (length=7) 'tab_group_code' => null
Get Eav Attribute Group Details by Group Id Magento 2. get($groupId) method from Product AttributeGroup Repository Interface return the attribute group information