cancel
Showing results for 
Search instead for 
Did you mean: 

How to Display Attribute Group Name in Product Tab Magento 2.1.3

How to Display Attribute Group Name in Product Tab Magento 2.1.3

How to Display Attribute Group Name in Product Tab Magento 2.1.3

2 REPLIES 2

Re: How to Display Attribute Group Name in Product Tab Magento 2.1.3

Hi @optimyle_optimy 

 

You can get Attribute group name using attribute code and attribute set id.


Try the following code once:

<?php 
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$productCollection = $objectManager->create('Magento\Eav\Model\ResourceModel\Entity\Attribute\Group\Collection');
$productCollection->addAttributeToSelect('*');
$productCollection->addFieldToFilter('attribute_set_id',4)->addAttributeToSort('attribute_set_id', 'asc');
$productCollection->load();
foreach ($productCollection as $key => $value)
{
echo '<pre>'; print_r($value->getData());
}


Or check the below link. 

magento-2-get-product-attributes-attribute-groups/

 

I hope it will help you!

Re: How to Display Attribute Group Name in Product Tab Magento 2.1.3

Hi @optimyle_optimy ,

 

Try to make a module and create a view layout "catalog_product_view.xml". Add xml

 

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceBlock name="product.info.details">
<block class="Magento\Catalog\Block\Product\View" name="tab.tab" template="OverrideProductTab_Producttab:Smiley Tongueroducttab.phtml" group="detailed_info" >
<arguments>
<argument translate="true" name="title" xsi:type="string">Group Attribute</argument>
</arguments>
</block>
</referenceBlock>
</body>
</page>
</referenceBlock>

 

create a templates producttab.phtml add the line.

<?php $product = $block->getProduct(); ?>
<h1 style="color: #ff6e17"><?php echo $product->getData('producttab'); ?></h1>

After that run the below command.
sudo php bin/magento setup:static-content:deploy
sudo php bin/magento cache:clean

sudo php bin/magento cache:flush

 

After that product tab will be display and add logic here.


If my answer is useful, please Accept as Solution & give Kudos

@siddiqui208