2

I want to import product with attribute value Price , description and store in csv file using Beanshell script .

2 Answers2

0

You can use export in Hac using a specific impex header.

I don't know the requirement but it's not proper to do it using beanshell since we have and import export framework.

You might have a look DefaultExportService. It can be used in a shell Script.

0

You could restrict your search results to return only a certain catalog/version(use in Hac/hMC):

$catalog=YourCatalogId
$version=YourCatalogVersion
"#% import de.hybris.platform.jalo.product.Product;"
"#% impex.setTargetFile( ""Products_and_price.csv"", true, 1, -1 );"
INSERT_UPDATE Product;code[unique=true];description[lang=en];description[lang=de];europe1Prices(price,currency(isoCode))
"#% impex.exportItems("" SELECT {p:pk} FROM {Product as p JOIN CatalogVersion as cv ON {cv:PK}={p:catalogVersion} JOIN catalog as c ON {c:pk}={cv:catalog}} WHERE {c:id}='$catalog' AND {cv:version}='$version'"", Collections.EMPTY_MAP, Collections.singletonList( Product.class ), true, true, -1, -1 );"

Add more languages for description if needed. Products are linked to their store through their catalog. You could search for this relation (catalog-store) on a new line, I'm not sure how to display this in one line.

thijsraets
  • 573
  • 1
  • 5
  • 13