0

'system' attribute property tells if attribute is system defined or not.

'user_defined' attribute property tells if attribute is custom (define by developer) or not.

It means, if 'system'=0, the attribute is 'user_defined' and vice versa.

So why Magento 2 uses two property (system, user_defined) for the same reason ? If they are different then how ?

2 Answers 2

0
  1. Actually, Magento user_defined = false attributes are known as system attributes. So Magento has some of their system attribute, which we can not delete from the admin panel. So Magento won't allow system attributes to be deleted. We can delete them through the database but it is not safe.

OR

  1. user_defined = false for Magento default attributes which are required for some functionalities to work or any module providing some additional feature based on an attribute, like SKU, qty, website_ids, product_online are system attributes required to manage quantity and scope of product, same way is_featured or show_on_homepage can be some attribute doing something in the backend to provide some feature and shouldn't be deleted by admin user that may break the functionality.

AND

  1. user_defined = true attributes are generally created by the catalog managers to have product specific information. So Admin users can delete these attributes from the admin panel.

For more infomation check below link.

What's the difference between an user defined attribute and non user defined attribute?

Thanks.

0

system and user_defined attribute properties are different and do different jobs. In the database, system attribute property save in is_system column and user_defined attribute property save in is_user_defined column.

Especially, system attribute property is only used for Customer entity (customer_eav_attribute table) while user_defined is used for all entities (eav_attribute table).

You can check prefix attribute, which has system value is 0 and user_defined value is 0 to confirm 'system' = 0 does not mean the attribute is 'user_defined'.

Magento uses system attribute property to define whether an attribute is a custom attribute or system attribute.

While Magento uses user_defined attribute property to define whether an attribute is an attribute defined by the user or system attribute (not the system attribute property mentioned above).

See how Magento uses both system (isSystem()) and user_defined (isUserDefined()) attribute properties in vendor/magento/module-sales/Block/Adminhtml/Order/View/Info.php, method getCustomerAccountData().

See how Magento uses system attribute property in:

  • vendor/magento/module-sales/Block/Adminhtml/Order/View/Info.php, method getCustomerAccountData().
  • vendor/magento/module-customer/Model/Metadata/CustomerMetadata.php, method getCustomAttributesMetadata.
  • vendor/magento/module-customer/Model/Metadata/AddressMetadata.php, method getCustomAttributesMetadata().

See how Magento uses user_defined attribute property in:

  • vendor/magento/module-sales/Block/Adminhtml/Order/View/Info.php, method getCustomerAccountData().
  • vendor/magento/module-checkout/Model/DefaultConfigProvider.php, method getAddressFromData.
  • vendor/magento/module-customer/Controller/Account/CreatePost.php, method extractAddress().
  • vendor/magento/module-customer/Model/Metadata/Form.php, method getUserAttributes and getSystemAttributes.
  • vendor/magento/module-customer/Controller/Account/CreatePost.php, method extractAddress().
2
  • thanks for the response Tu. my question is why we're using two property for the same job ? system = 0 and user_defined = 1 OR system =1 and user_defined = 0...either we can use system or user_defined for the job. how both are different ? Commented Dec 17, 2022 at 16:51
  • @WakarAhamad I've updated my answer, please check.
    – Tu Van
    Commented Dec 17, 2022 at 17:30

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.