I try to create a category attribute in a Magento 2 install script (or how do we call these now?)
In Magento 1, I could specify anything as group
and the group would be created. In Magento 2 this seems not to be the case anymore, so I created the group explicitly first:
$eavSetup->addAttributeGroup(
Category::ENTITY,
$eavSetup->getDefaultAttributeSetId(Category::ENTITY),
'My group name',
99
);
$eavSetup->addAttribute(
Category::ENTITY,
'my_attribute_code',
[
'type' => 'int',
'input' => 'select',
'source' => Boolean::class,
'label' => 'My attribute',
'group' => 'My group name',
'visible' => 1,
]
);
The attribute and attribute group is created in the database (eav_attribute
and eav_attribute_group
, as well as the relation in eav_entity_attribute
) but I still do not see the attribute in the backend. What am I missing?