Hi,
I need to import a lot of data via CSV and discovered the CsvBulkLoader. I subclassed it for my needs:
class StudioCsvBulkLoader extends CsvBulkLoader {
//Key=CSV colum, Value=FitnessStudio attribute
public $columnMap = array(
'Studioname' => 'name',
'PLZ' => 'postcode',
'Stadt' => 'city',
'Strasse' => 'street',
'Land' => 'country',
'Vorwahl' => 'telephoncode',
'Telefonnummer' => 'telephon',
'URL' => 'URL',
'Kampagne' => 'Campaign.Title',
);
public $duplicateChecks = array(
'Studioname' => 'name'
);
//Define relation and function to check, if the category exists.
public $relationCallbacks = array(
'relationname' => 'Campaign',
'callback' => 'getClientCategoryByTitle'
);
//Does the imported category already exist?
static function getClientCategoryByTitle(&$obj, $val, $record){
$SQL_val = Convert::raw2sql($val);
return DataObject::get_one(
'Campaign', "Title = '{$SQL_val}'"
);
}
}
I implemented the StudioCsvBulkLoader into a subclass of ModelAdmin. My problem: StudioCsvBulkLoader does not work. Any changes I do to $columnMap or any other variable does not show any effect to the backend. The system seems to fall back on CsvBulkLoader. Do I have any stupid coding mistake?