AD0-E716 · Question #30
An Adobe Commerce Developer has written an importer and exporter for a custom entity. The client is using this to modify the exported data and then re-importing the file to batch update the…
The correct answer is A. Option A. The _transformAttrs class property array of the importer and exporter classes can be used to specify a serializer class for a particular attribute. The serializer class will be used to convert the attribute value from one format to another when the data is exported or imported…
Question
An Adobe Commerce Developer has written an importer and exporter for a custom entity. The client is using this to modify the exported data and then re-importing the file to batch update the entities. There is a text attribute, which contains information related to imagery in JSON form, media_gallery. This is not a field that the client wants to change, but the software they are using to edit the exported data seems to be modifying it and not allowing it to import correctly. How would the developer prevent this?
Options
- AOption A
- BOption B
- COption C
How the community answered
(37 responses)- A70% (26)
- B22% (8)
- C8% (3)
Explanation
The _transformAttrs class property array of the importer and exporter classes can be used to specify a serializer class for a particular attribute. The serializer class will be used to convert the attribute value from one format to another when the data is exported or imported. In this case, the developer can specify a serializer class that will convert the JSON data in the media_gallery attribute to a string. This will prevent the software that the client is using to modify the exported data from changing the JSON data. The following code shows how to specify a serializer class for the media_gallery attribute: class MySerializer public function serialize($value) return json_encode($value); public function deserialize($value) return json_decode($value); $importer->setSerializer('media_gallery', MySerializer::class); $exporter->setSerializer('media_gallery', MySerializer::class); Once the serializer class has been specified, the JSON data in the media_gallery attribute will be converted to a string when the data is exported or imported. This will prevent the software that the client is using to modify the exported data from changing the JSON data.
Topics
Community Discussion
No community discussion yet for this question.