ExamGecko
Question list
Search
Search

List of questions

Search

Related questions











Question 30 - AD0-E716 discussion

Report
Export

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?

A) Specify a serializer class for the attribute using the $_transformAttrs class property array for both the exporter and importer so it gets converted:

B) Strip the attribute from the imported file by adding it to the s_strippedAttrs class property array:

C) Prevent it from being exported by adding it to the $_disat>iedAttrs class property array:

A.
Option A
Answers
A.
Option A
B.
Option B
Answers
B.
Option B
C.
Option C
Answers
C.
Option C
Suggested answer: A

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:

PHP

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.

asked 02/10/2024
alvaro Vasconcelos
35 questions
User
Your answer:
0 comments
Sorted by

Leave a comment first