如何使用impex在Hybris中只导出一种产品

时间:2015-12-31 16:43:57

标签: hybris impex

我想使用hybris impex只输出一种产品:
以下sql给我那个产品。

select * from products where code='489923'

我正在尝试修改导出脚本:

# ---- 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 );"

如下:

# ---- 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 );"

这样我只能导出一种产品。但是它给了我错误?此外,我不知道如何查看错误的详细信息。

2 个答案:

答案 0 :(得分:1)

您可以在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'"" );"

您可以在下面下载文件

答案 1 :(得分:0)

当您尝试调用函数exportItems时,impex文件中有错误。

根据您的Hybris版本,exportItems函数有多种形式:

    // 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 )

就我而言,我使用了seconde表格来导出产品:

"#% impex.exportItems( ""select {K.pk} from {Product K}"", Collections.EMPTY_MAP, Collections.singletonList( Item.class ), true, true, -1, -1 );"
亚当,当你加上引号时要小心:

      "#% impex.exportItems(""SELECT {K:pk} FROM {Product as K} WHERE {K:code}='489923'  , false );"