Open textarea opened 4 years ago
Hi @textarea. Thank you for your report. To help us process this issue please make sure that you provided the following information:
Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:
@magento give me 2.4-develop instance
- upcoming 2.4.x release
For more details, please, review the Magento Contributor Assistant documentation.
@textarea do you confirm that you were able to reproduce the issue on vanilla Magento instance following steps to reproduce?
Hi @engcom-Hotel. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:
[ ] 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).Details
If the issue has a valid description, the label Issue: Format is valid
will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid
appears.
[ ] 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description
label to the issue by yourself.
[ ] 3. Add Component: XXXXX
label(s) to the ticket, indicating the components it may be related to.
[ ] 4. Verify that the issue is reproducible on 2.4-develop
branchDetails
- Add the comment @magento give me 2.4-develop instance
to deploy test instance on Magento infrastructure.
- If the issue is reproducible on 2.4-develop
branch, please, add the label Reproduced on 2.4.x
.
- If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!
[ ] 5. Add label Issue: Confirmed
once verification is complete.
[ ] 6. Make sure that automatic system confirms that report has been added to the backlog.
:white_check_mark: Confirmed by @engcom-Hotel
Thank you for verifying the issue. Based on the provided information internal tickets MC-30919
were created
Issue Available: @engcom-Hotel, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.
FYI can't reproduct on 2.3.3
@willtran I can reproduce this issue on 2.3.3 also.
@willtran this issue is reproducible on 2.4-develop
Hi @sanjay-wagento. Thank you for working on this issue. Looks like this issue is already verified and confirmed. But if you want to validate it one more time, please, go though the following instruction:
[ ] 1. Add/Edit Component: XXXXX
label(s) to the ticket, indicating the components it may be related to.
[ ] 2. Verify that the issue is reproducible on 2.4-develop
branchDetails
- Add the comment @magento give me 2.4-develop instance
to deploy test instance on Magento infrastructure.
- If the issue is reproducible on 2.4-develop
branch, please, add the label Reproduced on 2.4.x
.
- If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!
[ ] 3. If the issue is not relevant or is not reproducible any more, feel free to close it.
@magento-engcom-team I have checked in Magento 2.4-develop branch with custom module and I can not reproduce issue.
@sanjay-wagento can you share your custom module?
@magento give me 2.4-develop instance
Hi @textarea. Thank you for your request. I'm working on Magento 2.4-develop instance for you
Hi @textarea, here is your Magento instance.
Admin access: https://i-26582-2-4-develop.instances.magento-community.engineering/admin_a2e3
Login: 527ca76b
Password: 813708a3759c
Instance will be terminated in up to 3 hours.
I'm unable to reproduce above issue in Magento 2.4-develop branch with custom module.
Below is the code of the custom module: http://www.mediafire.com/file/ev813ldhnhsolpl/rendyep.tar.gz/file
Extract the compressed file, put it on app/code/
, enable the module (Rendyep_Test
), run the upgrade script, and execute bin/magento rendyep:test:test
from terminal to see the result. The result can also be checked from database on table rendyep_test_test
after executing the console command from terminal.
Hi @rendyep , your module works, but I replicated it using Data\Interface instead of Model and it doesn't works.
Please give it a try with these sources: https://www.mediafire.com/file/qmgjqadpn5ixbbr/Acme.zip/file
Same instructions as yours, run bin/magento acme:test:test then check db table acme_test_test, detail column will remain filled.
@textarea the issue is in your repository class:
$testData = $this->extensibleDataObjectConverter->toNestedArray(
$test,
[],
\Acme\Test\Api\Data\TestInterface::class
);
$testModel = $this->testFactory->create()->setData($testData);
try {
$this->resource->save($testModel);
} catch (\Exception $exception) {
throw new CouldNotSaveException(__(
'Could not save the test: %1',
$exception->getMessage()
));
}
return $testModel->getDataModel();
The value $testData
of the first line when you call toNestedArray
would only get test_id
, no detail
, so when you call $testModel = $this->testFactory->create()->setData($testData);
, only test_id
is filled. To be clear, this is the output of the model values just before you save.
value of $testModel->getData():
array(1) {
["detail"]=>
string(9) "765321651"
}
Data before set detail to null:
string(9) "765321651"
value of $testModel->getData():
array(1) {
["test_id"]=>
string(2) "15"
}
That is why, when you save that model, the data other than test_id
would be saved to database, and the others remain as they are in current values.
The null value is not converted as null to $testData
because you don't mark the getDetail
method in Acme\Test\Api\Data\TestInterface
as required, therefore the converter skips the null value.
https://github.com/magento/magento2/blob/c43d76343807540acf71b630fd2916570d79f0ff/lib/internal/Magento/Framework/Reflection/DataObjectProcessor.php#L90-L97
Thanks @rendyep,
that code is generated by mage2gen, however, how to mark the getDetail
method in Acme\Test\Api\Data\TestInterface
as required?
Thanks
Ok @rendyep, I removed @return string|null and left @return string in getDetail() method and now NULL value is saved. However I don't think this is the right solution, it is still a bug.
@textarea could you please make sure that the value is NULL, not empty string?
@rendyep yes I'm sure
We can confirm that saving a field to NULL doesn't set the custom field.
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. Is this issue still relevant? If so, what is blocking it? Is there anything you can do to help move it forward? Thank you for your contributions!
Keep it live please
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. Is this issue still relevant? If so, what is blocking it? Is there anything you can do to help move it forward? Thank you for your contributions!
anyone can take a look into this?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 28 days if no further activity occurs. Is this issue still relevant? If so, what is blocking it? Is there anything you can do to help move it forward? Thank you for your contributions!
Preconditions (*)
Steps to reproduce (*)
Expected result (*)
Actual result (*)