-
Notifications
You must be signed in to change notification settings - Fork 9.4k
magento/magento2#14510: Creating custom customer attribute with default value 0 will cause not saving value for customer entity. #16915
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
Conversation
Hi @swnsma. Thank you for your contribution
For more details, please, review the Magento Contributor Assistant documentation |
Hi @swnsma , please, take a look at failed integration tests |
…0 will cause not saving value for customer entity. - fix default value check in case of type conversion; - add boolean attribute default value assignment;
c8f5238
to
5fa4d5f
Compare
Hi @sidolov, I have checked the error, and found next:
My assumption of the solution:
|
…0 will cause not saving value for customer entity. - remove default value for 'links_exist' attribute of Downloadable Product;
03ac7a3
to
0698aa6
Compare
} | ||
|
||
/** | ||
* {@inheritdoc} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove curly braces {}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! The sniffer checks only changed files so that's okay
…0 will cause not saving value for customer entity. Remove curly braces.
*/ | ||
public function getDefaultValue() | ||
{ | ||
if ($this->_defaultValue === null) { | ||
if ($this->getAttribute()->getDefaultValue()) { | ||
if ($this->getAttribute()->getDefaultValue() !== null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here you touch the logic that relates to all attributes. Are you sure that all other attributes have null
as default value? Won't it break their work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @slavvka,
I have two arguments for this point.
First: auto tests have passed successfully.
Second: if you look at the screenshot under, there are list of attributes with default value '0'. After smoke check I have not found strict check '===' with null or 0 values anymore (exception - 'links_exist' attribute).
So, I assume, there should not be any problems for existing set of attributes.
P.S. have checked on Open Source Magento.
Hi @slavvka, thank you for the review. |
…value 0 will cause not saving value for customer entity. #16915
Hi @swnsma. Thank you for your contribution. Please, consider to port this solution to 2.3 release line. |
Description
Fixed Issues
Manual testing scenarios
Steps to
Create attribute with type "boolean" and default value via Data Install.
Open Swagger.
Create new product with REST API via CATALOGPRODUCTREPOSITORYV1. Attribute 'custom_product' should be missed.
{ "product": { "status": 2, "visibility": 4, "type_id": "simple", "sku": "testattr", "name": "TEST ATTR", "attribute_set_id": 4, "price": 0.5, "weight": 0.0, "extension_attributes": { "stock_item": { "qty": 0, "is_in_stock": true, "use_config_backorders": false, "backorders": 1, "use_config_manage_stock": false } }, "custom_attributes": [ { "attribute_code": "description", "value": "" }, { "attribute_code": "short_description", "value": "" }, { "attribute_code": "weight", "value": "" } ] } }
Check a product attribute 'custom_product' value in DB.
Expected result
Actual result
Contribution checklist