import_impex
Import data into SAP Commerce Cloud using ImpEx format to manage products, orders, and configurations.
Instructions
Import data using ImpEx format
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| impexContent | Yes | ImpEx content to import |
Implementation Reference
- src/hybris-client.ts:514-584 (handler)The importImpex handler, implemented in HybrisClient, which executes a Groovy script on the Hybris server to import data using the ImportService.
async importImpex(impexContent: string): Promise<ImpexResult> { // Use Groovy script for ImpEx import with ImportService const escapedContent = this.escapeGroovyString(impexContent); const script = ` import de.hybris.platform.servicelayer.impex.ImportService import de.hybris.platform.servicelayer.impex.ImportConfig import de.hybris.platform.servicelayer.impex.impl.StreamBasedImpExResource try { def impexContent = "${escapedContent}" def importService = spring.getBean("importService") def config = new ImportConfig() def resource = new StreamBasedImpExResource( new ByteArrayInputStream(impexContent.getBytes("UTF-8")), "UTF-8" ) config.setScript(resource) config.setEnableCodeExecution(true) def importResult = importService.importData(config) if (importResult.hasUnresolvedLines()) { println "WARNING: Import completed with unresolved lines" importResult.unresolvedLines.allLines.each { line -> println " Unresolved: " + line } } if (importResult.isError()) { println "ERROR: Import failed" if (importResult.unresolvedLines?.allLines) { importResult.unresolvedLines.allLines.each { line -> println " Error: " + line } } return "ERROR" } println "SUCCESS: ImpEx import completed" return "SUCCESS" } catch (Exception e) { println "ERROR: " + e.getMessage() e.printStackTrace() return "ERROR: " + e.getMessage() } `; const result = await this.executeGroovyScript(script, true); // commit=true for imports const output = result.output || ''; const execResult = String(result.result || ''); const success = output.includes('SUCCESS:') || execResult === 'SUCCESS'; const errors: string[] = []; // Extract unresolved lines as errors const unresolvedMatch = output.match(/Unresolved: (.+)/g); if (unresolvedMatch) { errors.push(...unresolvedMatch); } const errorMatch = output.match(/ERROR: (.+)/); if (errorMatch) { errors.push(errorMatch[1]); } return { success, message: output || execResult, errors: errors.length > 0 ? errors : undefined, }; } - src/index.ts:430-434 (registration)Registration and invocation of the import_impex tool in the main MCP server request handler.
case 'import_impex': result = await hybrisClient.importImpex( validateString(args, 'impexContent', true) ); break;