How can I add an eav attribute for store? I practically need to add a post code but storeview scope. The problem is that the post code for store information has website scope.

I have addedd eav attributes before, but what would be the ENTITY and how can I change to storeview scope?

Something like this:

/** @var EavSetup $eavSetup */
            $eavSetup = $this->eavSetupFactory->create(['setup' => $setup]);
            * Add attributes to the eav/attribute
                    'group' => 'General',
                    'type' => 'int',
                    'backend' => '',
                    'frontend' => '',
                    'label' => 'Post Code',
                    'input' => 'text',
                    'class' => '',
                    'source' => 'Magento\Eav\Model\Entity\Attribute\Source\Boolean',
                    'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_GLOBAL,
                    'visible' => true,
                    'required' => false,
                    'user_defined' => false,
                    'default' => '1',
                    'searchable' => false,
                    'filterable' => false,
                    'comparable' => false,
                    'visible_on_front' => false,
                    'used_in_product_listing' => false,
                    'unique' => false,
                    'apply_to' => ''

This is the place where I need to add it.

enter image description here


  • Would you add the new filed in store information ,right ? Oct 17 '20 at 5:14

Store information is not an EAV attribute so you will have to take a different approach.

It is a system config value stored in the core_config_data table, these values are configured using /etc/adminhtml/system.xml.

Postcode is defined in the Magento_Backend module. To change the scope of this variable you will have to override it and change the scope for postcode that is set in:


I would recommend creating your own module with these files:


<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
        <section id="general">
            <group id="store_information">
                <field id="postcode" translate="label" type="text" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="1">
                    <label>ZIP/Postal Code - Override</label>

app/code/StackExchange/StoreInformation/etc/module.xml (the sequence is important here)

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    <module name="StackExchange_StoreInformation" setup_version="0.1.0">
            <module name="Magento_Backend"/>



Enable the module from cli Run setup:upgrade

You will then have the attribute in the correct scope as expected:

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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