I currently have a working method which allows me to create an attribute set on the fly. This works well:
public function createAttributeSets($attribute_set_name) {
$attr_set_id = $this->getAttrSetId("generated_" . $attribute_set_name);
if (!$attr_set_id) {
$entityTypeCode = 'catalog_product';
$entityType = $this->eavTypeFactory->create()->loadByCode($entityTypeCode);
$defaultSetId = $entityType->getDefaultAttributeSetId();
$attributeSet = $this->attributeSetFactory->create();
$data = [
'attribute_set_name' => $attribute_set_name,
'entity_type_id' => $entityType->getId(),
'sort_order' => 200,
];
$attributeSet->setData($data);
try {
$this->attributeSetManagement->create($entityTypeCode, $attributeSet, $defaultSetId);
} catch (Exception $e) {
}
return $attributeSet->getId();
} else {
return $attr_set_id;
}
}
Now I'd like to create an attribute group within this attribute set so that it's ready to place my new attributes within it.
Is this group automatically created if I assign a new attribute to a non-existing group name when I create it?