cancel
Showing results for 
Search instead for 
Did you mean: 

Running an impex via cron job

Former Member
0 Kudos

Hi,

Is there any way which we can run an impex from a cron job and the values of impex will be dynamically changed. Assuming impex is to create categories from an excel sheet which are stored as MediaItem in HMC.And business team will make the excel available in a predefined location.

0 Kudos

You can use scrpting jobs in hybris to acheive this. Check Scripting in backoffice left navigation explorer

import de.hybris.platform.util.CSVConstants;
import de.hybris.platform.servicelayer.impex.ImpExResource;
import de.hybris.platform.servicelayer.impex.ImportResult;
import de.hybris.platform.servicelayer.impex.impl.FileBasedImpExResource;
import java.io.File;

importImpex("/opt/hybris/bin/custom/<your-extension>/resources/<extension-folder>/import/your_impex.impex");

def importImpex(String filepath) {
final ImpExResource mediaRes = new FileBasedImpExResource(new File(filepath), CSVConstants.HYBRIS_ENCODING);
importService.importData(mediaRes);

}

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Matty,

Follow the below process in Order to generate Impex file. In a Cron job, read the CSV file or excel file using the CSV readers utils, and get the content from the CSV, and formulate the impex by mapping the fields in CSV.

Use the Imprter api in Hybris import de.hybris.platform.impex.jalo.Importer; Please import the newly created Impex file.

Hope this answers your question. Please let me know if you require any other help.

THanks