Skip to main content
Version: 2025.11

Serialize Asset-Data

Overview

The bundle offers a "FieldSerializer" service. It can be used to serialize fields with asset data before exporting, this can be useful for export adapters.

Namespace

The service can be located here: Twocream\ShopwareConnectorBundle\Serializer\FieldSerializer

Methods

The service offers serialization methods for the following data types:

Asset

Name: serializeAsset

Output: An array of asset data with the following entries: 'mimetype', 'filename', 'path', 'modification-date', 'size', 'translations', 'thumbnails'

Arguments:

Name & Data TypeMandatoryDescription
?Asset $assetYesThe Asset object that is to be serialized.
AssetHelper $assetHelperYesAn instance of the AssetHelper class. See: Asset Helper.
array $thumbnailNamesNo - Default: []Specifies the thumbnails for which the asset should be generated.
array $metaFieldMappingNo - Default: []A mapping for differing metadata names.

By default the service assumes the names "title", "alt" & "copyright". If the actual metadata names differ from this, you can specify it here (e.g., ['title' => 'name'] if the metadata value for the title is actually called "name").
string $folderNo - Default: 'media'Optional subfolder within the defined asset path where the generated files will be stored.
?array $languagesNo - Default: nullA list of languages used for metadata translations.

ImageGallery

Name: serializeImageGalleryField

Output: An array with entries for each image in the gallery. Each entry contains an array with the following entries: 'mimetype', 'filename', 'path', 'modification-date', 'size', 'translations', 'thumbnails'

Arguments:

Name & Data TypeMandatoryDescription
?ImageGallery $imageGalleryYesThe ImageGallery object that is to be serialized.
AssetHelper $assetHelperYesAn instance of the AssetHelper class. See: Asset Helper.
array $thumbnailNamesNo - Default: []Specifies the thumbnails for which the asset should be generated.
array $metaFieldMappingNo - Default: []A mapping for differing metadata names.

By default the service assumes the names "title", "alt" & "copyright". If the actual metadata names differ from this, you can specify it here (e.g., ['title' => 'name'] if the metadata value for the title is actually called "name").
string $folderNo - Default: 'media'Optional subfolder within the defined asset path where the generated files will be stored.
?array $languagesNo - Default: nullA list of languages used for metadata translations.

Video

Name: serializeVideoField

Output: An array of video data with the following entries: 'type', 'title', 'description', 'date', 'youtube-id'

Arguments:

Name & Data TypeMandatoryDescription
?AbstractObject $videoObjectYesThe DataObject which contains the video field that is to be serialized.
string $videoFieldIdentifierYesThe field name of the video field.
array $fieldMappingYesA mapping for differing names of video data fields.

By default the service assumes the names "title", "description" & "date". If the actual field names differ from this, you can specify it here (e.g., ['title' => 'name'] if the title field is actually named "name").
?string $languageNo - Default: nullThe language used for the video data. This is only necessary if the field is localized.

Video (Multi-Language)

Name: serializeMultiLanguageVideoField

Output: An array with the entry 'translations'. This contains an array with video data for each language. Each language entry has the following data entries: 'type', 'title', 'description', 'date', 'youtube-id'

Arguments:

Name & Data TypeMandatoryDescription
?AbstractObject $videoObjectYesThe DataObject which contains the video field that is to be serialized.
string $videoFieldIdentifierYesThe field name of the video field.
array $fieldMappingYesA mapping for differing names of video data fields.

By default the service assumes the names "title", "description" & "date". If the actual field names differ from this, you can specify it here (e.g., ['title' => 'name'] if the title field is actually named "name").
array $languagesYesA list of languages the video data should be serialized in.
?string $defaultVideoFieldIdentifierNo - Default: nullThe default field name of a video field whose data should be used if no data is found for a language. The default language is used here.
?string $defaultLanguageNo - Default: nullThe language for which data should be obtained from the default field if no data is found for a language.