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
Custom attributes do not work as intended #4703
Comments
Note: This is a larger issue for those leveraging the webapi data object input converter. That converter will throw exceptions when any input keys reference attribute codes not present in the ProductInterface schema, hence they must be set in a nested |
I'm not sure of the issue, but I think they do work, but they're a bit confusing. Maybe you can find something useful in this discussion: http://magento.stackexchange.com/questions/87452/how-do-the-extension-attributes-work-in-magento-2 |
Are you sure the products attribute set contains the custom attribute, and that the attributes property Note: this is about custom attributes, not extension attributes, right? |
Correct, but there's some mentioning about custom attributes in that SO link, too. |
Yes @Vinai the attributes are user defined and set up properly. See the code I linked above, it is very clear that anything set via |
Bump. I don't think core team realizes this is a rather large oversight which makes the entire webapi for EAV entities close to useless. Should be a high priority. |
@samtay, thank you for reporting. Please, provide the used version. If the problem is actual for a specific tag, please, specify it and be sure that the latest update was used. |
I found it on EE 2.0.7 but it still exists on the CE develop branch.. just look at the code link I posted in my initial comment, it should be obvious. |
@samtay |
Step 1.Clone Magento2 from any version since general availability. Step 2.Set up access to product repository API such as through test framework/module Step 3.[Insert original issue comment] The only way to have these work as intended is to use a builder such as RecapAny time a product model |
I've stumbled upon this issue as I was getting the same error that custom attributes on a customer entity cannot be saved and get ignored.
After digging around for hours in the source code ... I realized that
Don't forget it to add it to an attribute set ;-) After that custom_attributes are not an issue anymore, at least on the customer entity 8-) |
@samtay, thank you for your report. |
Has anybody managed to make a patch for this in the meantime, or got a solid workaround? I'm thinking of using an observer on |
I'm not sure if is the same error, but looks like a lot to me. Loading a product by
To fix it, I use |
[tango] MC-19172: [backport for 2.2.10] backport fix for MC-18954 to 2.2.10 branch
I removed the label "Issue: Confirmed" it requires to be re-triaged/re-checked is a problem still actual for |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 14 days if no further activity occurs. Thank you for your contributions. |
See below example
ANY values in
$_data[self::CUSTOM_ATTRIBUTES]
is lost, and not saved properly.This is because the product repository issues a product model
load
which loads all attributes, custom or not, into the_data
array. Anytime the app callsProductInterface::getCustomAttributes
(which it does try to do when saving, to grab any values there) any custom attribute 'key' in$_data['custom_attributes']['key']
is overwritten because that key exists in$_data['key']
. This overwriting happens here.The text was updated successfully, but these errors were encountered: