implode cannot return imageGallery items paths in DataDirector bundle for Pimcore

60 Views Asked by At

I created dataDirector exporting dataport with raw field:

imageGallery:Items:implode:Thumbnail#somename:Path

It returns nothing '';

Athoug there is data in the gallery: if I change it to imageGallery:Items then I get

["/tmp/photo1.jpeg", "/tmp/photo2.jpeg"]

How can I get list of urls to asset images or/and their thumbnails?

1

There are 1 best solutions below

0
On

Image Gallery is processed by 'each', not 'all'.

Please try:

imageGallery:each:(Thumbnail#somename:Path):implode

(as ImageGallery implements PHP's Iterator interface you can skip the :items - but it would also not harm if you keep it)

If this does not work (currently am not sure about the parsing of the suffix aggregation), try

imageGallery:each:(Thumbnail#somename:Path) 

and apply implode() in attribute mapping.

Your current approach fetches the items (imageGallery:Items will return an array of HotspotImage objects - it only looks as if this would return an array of strings because the HotspotImage implements the __toString() method which returns the asset's path, see https://github.com/pimcore/pimcore/blob/6b2cd411b30e86d7f69dba1a9e7a7398b93c8c2e/models/DataObject/Data/Hotspotimage.php#L215-L222) and then implodes them to a string - this does not work.

I hope that all cases are covered in https://pimcore.blackbit.de/Blackbit/1.pimcore/Handb%C3%BCcher/Ultima-Import-Bundle.pdf - but just write your concrete use-case / question, then I will support you and probably add it to the docs.

Please also see https://www.youtube.com/watch?v=mAu_5Eg3q_o&list=PL4-QRNfdsdKIfzQIP-c9hRruXf0r48fjt&index=9 where I explain common use-cases for data query selectors.

(c) BlackbitDevs.