Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Customising the CMS /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Customizing the CsvBulkLoader

Go to End

2 Posts   1650 Views


Community Member, 279 Posts

15 September 2009 at 3:14am


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?


Community Member, 279 Posts

15 September 2009 at 3:32am

I have this solved ;) I had an error in the headrow of my csv.