Create a product group and create an attribute into that specific group…it’s quite easy in magento.
Ex :
public function createAttributeGroup($groupName,$order = 1)
{
$attributeSetId = $this->product->getDefaultAttributeSetId();
$attributeGroup = $this->attributeGroupInterfaceFactory->create();
$attributeGroup->setAttributeSetId($attributeSetId);
$attributeGroup->setAttributeGroupName($groupName);
$attributeGroup->setSortOrder($order);
$this->attributeGroupRepository->save($attributeGroup);
}
This is working fine and you will see a new fieldset in the product form page with the new attributes.
$eavSetup = $this->eavSetupFactory->create(['setup' => $this->moduleDataSetup]);
$this->createAttributeGroup('Ingredient INCI',10);
$attributeCodes = [
'ingredient_inci_1',
'ingredient_inci_2'
];
foreach ($attributeCodes as $k => $attributeCode){
$eavSetup->addAttribute(
Product::ENTITY,
$attributeCode,
[
'group' => 'Ingredient INCI',
'type' => 'text',
'backend' => '',
'frontend' => '',
'label' => 'Ingredient INCI '.($k+1),
'input' => 'select',
'class' => '',
'source' => Inci::class,
'global' => ScopedAttributeInterface::SCOPE_GLOBAL,
'visible' => true,
'required' => false,
'user_defined' => false,
'default' => '',
'searchable' => false,
'filterable' => false,
'comparable' => false,
'visible_on_front' => false,
'used_in_product_listing' => true,
'unique' => false,
'apply_to' => ''
]
);
But what I would like to achieve is to set extra fieldsets into the main one.
Meaning i would like to go from something like that
To something like that where INCI 1 / INCI 2 would be subgroups of INCI
Sadly I haven’t been able to find any way to do this in the product page.
Any idea ?