-
Notifications
You must be signed in to change notification settings - Fork 9.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
addAttribute mapping and updateAttribute confusions #1917
Comments
The GitHub issue tracker is intended for technical issues only. Please refer to the Community Forums or Magento Stack Exchange site for technical questions. In your case, the programming questions forum is likely the most appropriate. Feel free to reopen this issue if you think you have encountered a bug in Magento 2. |
@daim2k5 this is technical issue, not a question. |
@wojtekn ok, but you ask only two question. I still don't see a technical issue. Maybe you can describe it with more details? |
@daim2k5 issue is about inconsistency in M2 code, so I wouldn't consider this as question but technical issue. IMO it's confusing that you need to use two different key variants in install and upgrade scripts. |
@wojtekn is this issue still actual? |
@veloraven it's still not fixed, both methods accept different sets of arguments. Expected result is to have both methods accepting mapped properties or to have both methods accepting not mapped properties. It is confusing that "add" and "update" methods accept arguments in two different format. Assuming that currently there may exist huge amount of code relying on this (community extensions and other custom code), it would make sense to modify |
@wojtekn @daim2k5 @veloraven @daim2k5 @veloraven |
@wojtekn, thank you for your report. |
I'll add that the field map translation done in the addAttribute method is also doing more than just mapping. Mappers used such as Magento\Eav\Model\Entity\Setup\PropertyMapper are setting default values for missing fields, which means that if you try to update only a single field of an attribute with the addAttribute method you will end up with all other mapped attributes reset to their default values. For instance if you try to do the following: $this->eavSetupFactory->create(['setup' => $setup])
->addAttribute(
\Magento\Catalog\Model\Product::ENTITY,
'visibility',
['label' => 'Where it can be seen']
); The result will be the visibility attribute having the new custom label but being set from select to varchar type as well because of the mapper default values. In the end the attribute CRUD from the EavSetup class should be refactored to be indeed a bit more dev friendly. |
Hi @wojtekn thank you for your report. The method |
\Magento\Eav\Setup\EavSetup::addAttribute()
method uses property mapping but\Magento\Eav\Setup\EavSetup::updateAttribute()
doesn't. This mapping is done in classes:What is the point to copy this confusing feature from Magento 1 to Magento 2? Wouldn't it make more sense to use the same key names in both cases?
Preconditions
Steps to reproduce
Expected result
EavSetup::addAttribute and EavSetup::updatelAttribute signatures should be consistent (both accepting mapped properties or not mapped properties).
Actual result
EavSetup::addAttribute and EavSetup::updatelAttribute signatures are inconsistent.
The text was updated successfully, but these errors were encountered: