Import from cli/cronjob

Back in the days Vinai Kopp gave a talk about ImportExport module.

In the talk is a code snippet which helps to run importExport from CLI or as a cronjob. Unfortunately it is a screenshot and I typed the snippet already a couple of times. Time to make sure it is copy pastable:


require 'html/app/Mage.php';


/** @var $import Mage_ImportExport_Model_Import */
$import = Mage::getModel('importexport/import');
$file = './import.csv';

if (!$file || !file_exists($file)) {  
    echo 'File does not exist.';

$validationResult = $import->validateSource($file);

if ($import->getProcessedRowsCount() <= 0 || !$validationResult) {  
        'File %s contains %s corrupt records (from a total of %s)',
    foreach ($import->getErrors() as $type => $lines) {
        $lines = implode(', ', $lines);
        printf("\n:::: $type :::: \nIn Line(s) $lines \n");