What is the distinction between defining a custom attribute as "system" versus not "user defined"?

by RNanoware   Last Updated January 19, 2018 21:09 PM

General Context

When adding custom attributes to EAV-storage data types (such as customers and customer_addresses), two seemingly redundant configuration values are allowed to be passed in:

// File: InstallData.php

public function install(...) {
    /** @var Magento\Eav\Setup\EavSetup */
    $eavSetup = $this->eavSetupFactory->create(...);

            'system'       => true,
            'user_defined' => false

Other questions have addressed the question of what exactly a user_defined custom attribute means: the attribute is considered a "system" attribute (note the ambiguous terminology here), and as such it will not appear on the admin as removable because it is considered essential to the operation of Magento.

Specific Context

However, when omitting the system and user_defined configuration values altogether, I found that the attributes I defined defaulted to 'system' => true. When I later attempted to set and save those attributes via a repository, as such:

/** @var \Magento\Customer\Api\Data\AddressInterface */
$address = $this->addressRepository->getById(...);
$address->setCustomAttribute('my_custom_attr', 'my_custom_value');

...I found that my custom attribute was not even exposed by the engine, due to the following lines of code:

// File: Magento/Customer/Model/Metadata/AddressMetadata.php
// Lines: 121-143
public function getCustomAttributesMetadata($dataObjectClassName = AddressMetadataInterface::DATA_INTERFACE_NAME)
    foreach ($this->getAllAttributesMetadata() as $attributeMetadata) {
        if (!$isDataObjectMethod && !$attributeMetadata->isSystem()) {
            $customAttributes[] = $attributeMetadata;

(The link to the Magento source is here.)

I had to set 'system' => false in my InstallData.php script in order for the custom attribute to be accessible via the program, yet I left user_defined untouched.


What is the difference between these two configuration values from a human perspective? How do they affect each other, if at all?

Related Questions

Magento 2. Add attribute to Catalog Price Rule

Updated September 05, 2017 15:09 PM

Get product custom attribute data Magento 2?

Updated February 28, 2017 17:09 PM