1

I want to download all the images and thumbnails attached to the categories present with the help of a groovy or export script whichever is possible in Hybris.

How to download Images/thumbnails of categories in Hybris through groovy/export script?

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48

1 Answers1

3

You can do this using the Backoffice export tool like so:

Backoffice explorer tree

  • Paste the export script for the Media files you would like to download (example at the end)
  • Click Validate and then Save
  • Select 'Export (No re-import)'
  • Click 'Next'

Export wizard step 1

  • Now select checkbox 'Export as zip'
  • Click Start

Export as zip wizard step 2

  • Click DOWNLOAD under 'Exported Media zip'

Save media zip step 3

You should now have a zip of all the media files you want.

Example export script, just replace the placeholder with your catalog name and adjust the flexible search statement to suit your needs:

"#% impex.setTargetFile( ""Media.csv"" );"
$catalogName=YOUR_CATALOG_ID
$version=ONLINE
$mimeType=image/jpeg
INSERT_UPDATE Media;code[unique=true];catalogVersion(catalog(id),version)[unique=true];mime;realfilename;@media[translator=de.hybris.platform.impex.jalo.media.MediaDataTranslator][forceWrite=true]
"#% impex.exportItems(""SELECT {itm.pk} FROM {Media as itm}, {CatalogVersion as cv}, {Catalog as c} WHERE {itm.catalogversion} = {cv.pk} AND {cv.catalog} = {c.PK} AND {c.id} = '$catalogName' AND {cv.version} = '$version' AND {itm.mime} = '$mimeType'"", Collections.EMPTY_MAP, Collections.singletonList( Item.class ), true, true, -1, -1  );"

Unfortunately there's one final task required since the export will only be in .bin format. You'll need to customize the data media translator. The steps are in this SAP support note:

https://launchpad.support.sap.com/#/notes/0002335426

Oisín
  • 81
  • 4
  • Hi, Much appreciate your effort. In fact I was going to post the same solution. I also find out this option for zip from backoffice but not in HAC this morning. TY again Can you help me for one more issue that I am facing? ie.,- after I exported the zip for the images of media, the name of the images in the zip file have been generated according to the @media[translator=de.hybris.platform.impex.jalo.media.MediaDataTranslator] but i want the name of the images in the zip as their identifier(i.e.,code) or with any unique value present in its type to identify which images is for which media. – Notsosimple Feb 24 '22 at 15:45
  • The only thing I can think of is to download the exported media impex zip file and use Excel, Atom or some other tool to paste the impex lines next to the media file names. The lines in both zip files will be have matching line number ie. line 1 impex file line will match to line 1 media file line. Hopefully that makes sense? – Oisín Feb 28 '22 at 13:07