magento2: Product attributes product_type, type_id cannot be created/edited form admin

Preconditions (*)

  1. Magento 2.3.5-p1

Steps to reproduce (*)

  1. IF product attributes with following code does not exist product_type or type_id then attempt to create any of them
  2. ELSE edit any of them and change anything

Expected result (*)

  • Attribute is not saved. Error message is shown
  • text: Code “product_type” is a reserved key and cannot be used as attribute code.
  • text: Code “type_idis” a reserved key and cannot be used as attribute code.

Actual result (*)

  1. Either of following messages appear An attribute with this code already exists. OR An attribute with the same code (product_type) already exists. product_type type_id

It’s due to following line of code https://github.com/magento/magento2/blob/39012d4ea79157cb12eef348cc3448d955c0ecc5/app/code/Magento/Catalog/Controller/Adminhtml/Product/Attribute/Validate.php#L130 implemented in https://github.com/magento/magento2/commit/ca0da34ee2691bfaca1c74d94a0db33377d4e54c#diff-9ff38a88c1abf86286f77b64c8bc9b38 and https://github.com/magento/magento2/commit/b9d13e69c4928a0b6d740845bed305a399a42fd5#diff-9ff38a88c1abf86286f77b64c8bc9b38


Please provide Severity assessment for the Issue as Reporter. This information will help during Confirmation and Issue triage processes.

  • Severity: S0 - Affects critical data or functionality and leaves users without workaround.
  • Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
  • Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
  • Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
  • Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 22 (12 by maintainers)

Most upvoted comments

Hello @IgorM92 @AbdulRahmanAbouzaid

Thank you for your report and collaboration!

This issue has been reviewed and discussed during the Triage Meeting with Magento Product Managers.

The results and resolution based on https://github.com/magento/magento2/issues/28479#issuecomment-640722555

  • product_type and type_id are reserved keys in Magento that in use through a lot of functionality. So, allowing to save such names will required a lot of effort for development and testing and the final value does not worth it
  • But agree that we can improve error message to avoid possible confusion

The expected result should be updated:

  • Error message text: Code “product_type” is a reserved key and cannot be used as attribute code.
  • Error message text: Code “type_idis” a reserved key and cannot be used as attribute code.