Hybris : How to import media which is in the zip f

2019-08-04 11:14发布

I know we can import images which are not zipped like this

$siteResource=jar:com.project.initialdata.constants.ProjectInitialDataConstants&/projectinitialdata/import/sampledata/images/brand

INSERT_UPDATE Media ; code[unique=true]               ; mediaFormat(qualifier) ; realfilename                               ; @media[translator=de.hybris.platform.impex.jalo.media.MediaDataTranslator] ; mime[default='image/jpeg'] ; catalogVersion(catalog(id),version)[unique=true,allownull=true]
                    ; logo-molinard.jpg               ;                        ; Molinard_logo.jpg                          ; $siteResource/8918352691230.jpg                                                          ; image/jpeg                 ; hybrisContentCatalog:Staged                                    
                    ; Logo_LittleMarcel               ;                        ; LM_logo.jpg                                ; $siteResource/8918375858206.jpg                                                          ; image/jpeg                 ; hybrisContentCatalog:Staged   

But in my case I need to import the images which are in a zip file.

Update:

It works when I do like this:

$siteResource=zip:C:\HYBRIS_SERVER\hybris\bin\custom\project\projectinitialdata\resources\projectinitialdata\import\sampledata\images\brand

INSERT_UPDATE Media ; code[unique=true] ; mediaFormat(qualifier) ; realfilename      ; @media[translator=de.hybris.platform.impex.jalo.media.MediaDataTranslator] ; mime[default='image/jpeg'] ; catalogVersion(catalog(id),version)[unique=true,allownull=true]
                    ; logo-molinard.jpg ;                        ; Molinard_logo.jpg ; $siteResource/images.zip&8918352691230.jpg                                 ; image/jpeg                 ; hybrisContentCatalog:Staged                                    

Note above I'm giving an abolute path.

But when I tried to give relative path like this it didn't work

$siteResource=zip:com.project.initialdata.constants.ProjectInitialDataConstants&/projectinitialdata/import/sampledata/images/brand

INSERT_UPDATE Media ; code[unique=true] ; mediaFormat(qualifier) ; realfilename      ; @media[translator=de.hybris.platform.impex.jalo.media.MediaDataTranslator] ; mime[default='image/jpeg'] ; catalogVersion(catalog(id),version)[unique=true,allownull=true]
                    ; logo-molinard.jpg ;                        ; Molinard_logo.jpg ; $siteResource/images.zip&8918352691230.jpg                                 ; image/jpeg                 ; hybrisContentCatalog:Staged   

1条回答
ら.Afraid
2楼-- · 2019-08-04 12:04

You need to develop new translator. You can extend MediaDataTranslator for unzipping file. You can call base class for other operations.

Custom translator guideline: https://help.hybris.com/1811/hcd/ef51040168d743879c015b7de232ce40.html

Update
You need to use jar and zip together. May be you can get folder before zip like below:

$siteZipResource=jar:com.project.initialdata.constants.ProjectInitialDataConstants
$siteResource=zip:$siteZipResource&/projectinitialdata/import/sampledata/images/brand
查看更多
登录 后发表回答