4

I want to export only one product using hybris impex:
following sql give me that product.

select * from products where code='489923'

I am trying to modify the export script:

# ---- Extension: core ---- Type: Product ----
"#% impex.setTargetFile( ""Product.csv"" );"
insert_update Product;pk;Europe1PriceFactory_PDG(code,itemtype(code));Europe1PriceFactory_PPG(code,itemtype(code));Europe1PriceFactory_PTG(code,itemtype(code));approvalStatus(code,itemtype(code))[allownull=true];articleStatus[lang=en];buyerIDS(key(code,itemtype(code)));catalog(id)[allownull=true];catalogVersion(catalog(id),version)[unique=true,allownull=true];code[unique=true,allownull=true];contentUnit(code);creationtime[forceWrite=true,dateformat=dd.MM.yyyy hh:mm:ss];data_sheet(catalogVersion(catalog(id),version),code);deliveryTime;description[lang=en];detail(catalogVersion(catalog(id),version),code);ean;endLineNumber;erpGroupBuyer;erpGroupSupplier;europe1Discounts(pk);europe1Prices(pk);europe1Taxes(pk);galleryImages(catalogVersion(catalog(id),version),qualifier);logo(catalogVersion(catalog(id),version),code);manufacturerAID;manufacturerName;manufacturerTypeDescription[lang=en];maxOrderQuantity;minOrderQuantity;name[lang=en];normal(catalogVersion(catalog(id),version),code);numberContentUnits;offlineDate[dateformat=dd.MM.yyyy hh:mm:ss];onlineDate[dateformat=dd.MM.yyyy hh:mm:ss];order;orderQuantityInterval;others(catalogVersion(catalog(id),version),code);owner(pk)[allownull=true];picture(catalogVersion(catalog(id),version),code);priceQuantity;productOrderLimit(pk);remarks[lang=en];segment[lang=en];sequenceId;specialTreatmentClasses();startLineNumber;summary[lang=en];supplierAlternativeAID;thumbnail(catalogVersion(catalog(id),version),code);thumbnails(catalogVersion(catalog(id),version),code);unit(code);variantType(code);variants(catalogVersion(catalog(id),version),code);xmlcontent
"#% impex.exportItems( ""Product"" , false );"

as follows:

# ---- Extension: core ---- Type: Product ----
"#% impex.setTargetFile( ""Product.csv"" );"
insert_update Product;pk;Europe1PriceFactory_PDG(code,itemtype(code));Europe1PriceFactory_PPG(code,itemtype(code));Europe1PriceFactory_PTG(code,itemtype(code));approvalStatus(code,itemtype(code))[allownull=true];articleStatus[lang=en];buyerIDS(key(code,itemtype(code)));catalog(id)[allownull=true];catalogVersion(catalog(id),version)[unique=true,allownull=true];code[unique=true,allownull=true];contentUnit(code);creationtime[forceWrite=true,dateformat=dd.MM.yyyy hh:mm:ss];data_sheet(catalogVersion(catalog(id),version),code);deliveryTime;description[lang=en];detail(catalogVersion(catalog(id),version),code);ean;endLineNumber;erpGroupBuyer;erpGroupSupplier;europe1Discounts(pk);europe1Prices(pk);europe1Taxes(pk);galleryImages(catalogVersion(catalog(id),version),qualifier);logo(catalogVersion(catalog(id),version),code);manufacturerAID;manufacturerName;manufacturerTypeDescription[lang=en];maxOrderQuantity;minOrderQuantity;name[lang=en];normal(catalogVersion(catalog(id),version),code);numberContentUnits;offlineDate[dateformat=dd.MM.yyyy hh:mm:ss];onlineDate[dateformat=dd.MM.yyyy hh:mm:ss];order;orderQuantityInterval;others(catalogVersion(catalog(id),version),code);owner(pk)[allownull=true];picture(catalogVersion(catalog(id),version),code);priceQuantity;productOrderLimit(pk);remarks[lang=en];segment[lang=en];sequenceId;specialTreatmentClasses();startLineNumber;summary[lang=en];supplierAlternativeAID;thumbnail(catalogVersion(catalog(id),version),code);thumbnails(catalogVersion(catalog(id),version),code);unit(code);variantType(code);variants(catalogVersion(catalog(id),version),code);xmlcontent
"#% impex.exportItems(""SELECT {K:pk} FROM {Product as K} WHERE {K:code}='489923'  , false );"

so that I can export only one product. But it is giving me error? Also I am not sure how to see the details of the error.

Sanchit Khera
  • 1,005
  • 1
  • 16
  • 47
Adam
  • 41
  • 1
  • 2

2 Answers2

3

you can run below export impex in hac:

insert_update Product;pk;approvalStatus(code,itemtype(code))[allownull=true];articleStatus[lang=en];buyerIDS(key(code,itemtype(code)));catalog(id)[allownull=true];catalogVersion(catalog(id),version)[unique=true,allownull=true];
"#% impex.exportItemsFlexibleSearch( ""select {pk},{approvalStatus},{articleStatus},{buyerIDS},{catalog},{catalogVersion}from {Product} where {pk}='8799737217054'"" );"

A file will be available for you to download underneath

Maxwell Cheng
  • 1,050
  • 10
  • 17
0

You have an error in your impex file when you tried to call the function exportItems.

Based on your Hybris version, exportItems function have many form :

    // since 3.1-RC
    public void exportItemsFlexibleSearch( String query )
    public void exportItemsFlexibleSearch( String query, Map values, List resultClasses, final boolean failOnUnknownFields, final boolean dontNeedTotal, int start, int count )
    // since 3.1-u6
    public void exportItemsFlexibleSearch( String query, int count )

In my case, I used The seconde form to export products :

"#% impex.exportItems( ""select {K.pk} from {Product K}"", Collections.EMPTY_MAP, Collections.singletonList( Item.class ), true, true, -1, -1 );"

Adam, be careful when you put quotes :

      "#% impex.exportItems(""SELECT {K:pk} FROM {Product as K} WHERE {K:code}='489923'  , false );"
  • Thanks for helping. I tried above script and still getting following error: 16.01.11 07:10:23:256 ERROR line 5 at main script: error executing code line at 5 : Sourced file: inline evaluation of: ``impex.exportItems("SELECT {K:pk} FROM {Product as K} WHERE {K:code}='489923' , . . . '' Token Parsing Error: Lexical error at line 1, column 89. Encountered: after : "\"SELECT {K:pk} FROM {Product as K} WHERE {K:code}=\'489923\' , false );" I am using 4.8 version. – Adam Jan 11 '16 at 15:18
  • Try to this code : # ---- Extension: core ---- Type: Product ---- "#% impex.setTargetFile( ""Product.csv"" );" insert_update Product;pk "#% impex.exportItems( ""select {K.pk} from {Product AS K}"", Collections.EMPTY_MAP, Collections.singletonList( Item.class ), true, true, -1, -1 );" – Ouadie Lahdioui Jan 12 '16 at 16:19