I'm trying to create a global scoped category attribute, but it always seem to be scoped on store-level. I've got this:
$categorySetup->addAttribute(
$categorySetup->getEntityTypeId(Category::ENTITY),
CategoryMetaInterface::CATEGORY_CODE,
[
'type' => 'varchar',
'label' => 'Category Code',
'input' => 'text',
'unique' => true,
'required' => false,
'global' => ScopedAttributeInterface::SCOPE_GLOBAL,
]
);
This creates the attribute, but it does not set it's scope to GLOBAL; if I look into catalog_eav_attribute
, the is_global
-column is set to 0, but it should be 1. Even if I add:
$categorySetup->updateAttribute(
Category::ENTITY,
CategoryMetaInterface::CATEGORY_CODE,
'global',
ScopedAttributeInterface::SCOPE_GLOBAL
);
The scope is not adjusted. I already tried changing global
to is_global
, but with no luck. Any thoughts on this?
Another strange issue: also the setting of visible => true/false
does not seem to have any effect when it comes to categories. Is the catalog_eav_attribute
-table properly populated when it comes to category attributes?
UPDATE: Found the issue. It's almost too embarrassing to say but there was in fact another update script that also tried to create this attribute with the older settings (refactoring gone wrong). Removing this old (not-so-dead) code solved the issue for me.