I'm trying to create a global scoped category attribute, but it always seem to be scoped on store-level. I've got this:

        '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:


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.


3 Answers 3


I hope you have included \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface as I can see your setting scope ScopedAttributeInterface::SCOPE_GLOBAL and not like

'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_GLOBAL as in the core modules.


Try using full scope specification \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_GLOBAL sample attribute code

$eavSetup = $this->eavSetupFactory->create(['setup' => $setup]); $eavSetup->addAttribute(\Magento\Catalog\Model\Category::ENTITY, 'call_for_price', [ 'type' => 'int', 'label' => 'Call for Price?', 'input' => 'boolean', 'source' => 'Magento\Eav\Model\Entity\Attribute\Source\Boolean', 'visible' => true, 'default' => 0, 'required' => false, 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_GLOBAL, 'group' => 'General', ]);

  • This should not make a difference, because it's a PHP constant. You could also use 'global' => '1' to get the same result. But nevertheless, tried it, zero result. Apr 26, 2018 at 10:55

It will not update if attribute has been previously created so add $eavSetup->removeAttribute(\Magento\Catalog\Model\Category::ENTITY, 'attribute_code'); before addAttribute function

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.