CRM and CX Blogs by SAP
Stay up-to-date on the latest developments and product news about intelligent customer experience and CRM technologies through blog posts from SAP experts.
cancel
Showing results for 
Search instead for 
Did you mean: 
priti_mittal
Product and Topic Expert
Product and Topic Expert
37,952
Objective : The intent of this article is to provide the solution for the use case -“Export the data from Online catalog version and import to Staged catalog version” .

Problem Summary : There are the instances where business wants to edit/update the Content/Product data such as name, description , media etc  in dedicated Hybris system before go live and doesn’t want to update the data via hybris impex file . Since online version would have the verified data to move to higher hybris environments hence it becomes necessary to export the data from online catalog version and import to Stage version on other environments (followed by sync process) .

Solution :  One of the ready to use solution is to write export-import script . This article explains all the steps to write/export/import  the script . Steps are as follows ,

step-1 : HAC - Data Export

  • Export the data with the help of export script .

  • Example : export Media from content catalog Online version .


$catalog=shakleeUSContentCatalog

$version=Online

# ---- Extension: core ---- Type: Media ----

"#% impex.setTargetFile( ""Media.csv"" );"

insert_update Media;URL;altText;catalog(id)[allownull=true];catalogVersion(catalog(id),version)[unique=true,allownull=true];code[unique=true,allownull=true];description;folder(qualifier);internalURL;location;locationHash;mediaContainer(catalogVersion(catalog(id),version),qualifier);mediaFormat(qualifier);mime;realFileName;removable[allownull=true];size;subFolderPath

"#% impex.exportItems(""SELECT {M:pk} FROM {Media as M}, {CatalogVersion as CV}, {Catalog as C} WHERE {M:catalogversion}={CV:PK} AND {CV:catalog}={C:PK} AND {C:id}='$catalog' AND {CV:version}='$version'"", Collections.EMPTY_MAP, Collections.singletonList( Item.class ), true, true, -1, -1 );"


 

  • Go to Hybris admin console ->Export . Copy paste above script in content area of Export Content tab and follow the steps mentioned in below image .




  • Download exported data and extract the zip file .


 



 

step-2 : **Edit importscript.impex and create a zip file

  • Open importscript.impex file in text editor .Before edit , file content would look like ,




  • Edit the file and add below line before Line "#% impex.includeExternalDataMedia(….


"#% beforeEach: import org.apache.commons.lang.StringUtils;int size = line.size()+1;for (i=1; i<size; i++){String value = line.get(Integer.valueOf(i));if(StringUtils.contains(value, ""Online"")){String newValue = StringUtils.replace(value, "" Online "","" Staged "");line.put(Integer.valueOf(i), newValue);}} ;"


  • *After edit and save , file content would look like,



#-----------------------------------------------------------
insert_update Media;URL;altText;catalog(id)[allownull=true];catalogVersion(catalog(id),version)[unique=true,allownull=true];code[unique=true,allownull=true];description;folder(qualifier);internalURL;location;locationHash;mediaContainer(catalogVersion(catalog(id),version),qualifier);mediaFormat(qualifier);mime;realFileName;removable[allownull=true];size;subFolderPath

"#% beforeEach: import org.apache.commons.lang.StringUtils;int size = line.size()+1;for (i=1; i<size; i++){String value = line.get(Integer.valueOf(i));if(StringUtils.contains(value, ""Online"")){String newValue = StringUtils.replace(value, ""Online"",""Staged"");line.put(Integer.valueOf(i), newValue);}} ;"
"#% impex.includeExternalDataMedia( ""Media.csv"" , ""UTF-8"", ';', 1 , -1 );"
#-----------------------------------------------------------


  • Create a zip file again . To create a zip file ,

    • Select the importscript.impex file and *.csv file/files .

    • Right click and compress the items .






  • Newly zipped file would be used to import the data into Staged version.


 

step-3 : HAC - Data Import

  • Go to import script and follow the steps motioned in below image to import the same data.




  • Data would be successfully loaded to Stage version.


 

**This step is manual step . we can also introduce automation script to generate the zip file rather manually editing it.
2 Comments