I've created a custom module that includes a script (InstallData.php) that adds a new attribute to an existing attribute group (Product Label):
'group' => 'Product Label'
However, when I enable the module and run setup:upgrade, I receive the following error:
Installing data... SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '10-Product Label' for key 'EAV_ATTRIBUTE_GROUP_ATTRIBUTE_SET_ID_ATTRIBUTE_GROUP_NAME', query was: INSERT INTO `eav_attribute_group` (`attribute_set_id`, `attribute_group_name`, `sort_order`, `attribute_group_code`) VALUES (?, ?, ?, ?)
If I run the following database query I can see that there are two records with the group name 'Product Label', however I don't see these as duplicates as they belong to attribute set 10, and 4 respectively.
MariaDB [max]> select attribute_group_name, attribute_set_id from eav_attribute_group where attribute_group_name = 'Product Label';
+----------------------+------------------+
| attribute_group_name | attribute_set_id |
+----------------------+------------------+
| Product Label | 4 |
| Product Label | 10 |
+----------------------+------------------+
2 rows in set (0.00 sec)
Furthermore, I'm unable to delete these records as it will cause the attributes that are currently under those attribute labels to lose their current values.
Does anyone know what may be causing this issue? I have verified that the InstallData.php script works, by adding the attribute to the default group, this issue only occurs when adding the attribute to the attribute group 'Product Label'.