ModelAdmin - Excel Import/Export Customization and Bug Questions

SilverStripe 4

I’m using the default ModelAdmin CSVBulkUploader.

  1. Is there a way to import/overwrite only records that have changed, when doing the import? If not built-in, is there a tutorial I can use to get started? I’d like to simply check the column on each row for changes and replace the row if there are, but leave it untouched if there are not.

  2. Can I add the BOM (byte order marker) of UTF-8 to the exported CSV ? Currently, I have to export it, then convert it, etc, etc.

  3. There is a “Dummy Column” bug. I’m wondering if anyone else has experience mitigating that one. I have to insert a dummy column at the beginning of my CSV files in order for the import feature to work, which is ok, but not intuitive, and certainly not pretty for the client.

I found this tutorial: CSV Import – SilverStripe Documentation

I’ll post an answer if I figure it out before anyone responds.

In the meantime, any help is greatly appreciated!

Looking through those docs, when using the default ModelAdmin behavior, it seems that you don’t have to explicitly declare the $model_importers property:

private static $model_importers = [
  'Wine' => 'CsvBulkLoader',
 ];

But, if you’re creating your own custom uploader, you do need to set this explicitly, with the classname of the custom importer:

private static $model_importers = [
  'Wine' => 'WineCsvBulkLoader',
 ];

Next step is to actually create the ‘WineCsvBulkLoader’ class.