I have a model, ProgramClass, for which I'd like to be able use the CSV import functionality to load data. I am able to do so, BUT what happens is any relations (ie. has_one) are duplicated. Here is the model:
<?php
class ProgramClass extends DataObject {
static $singular_name = "Scheduled Class";
static $plural_name = "Scheduled Classes";
static $db = array(
'InviteOnly' => 'Boolean',
'AgeYoungestYear' => 'Int',
'AgeYoungestMonth' => 'Int',
'AgeOldestYear' => 'Int',
'AgeOldestMonth' => 'Int',
'StartingTime' => 'Time',
'EndingTime' => 'Time',
'NumberOfClasses' => 'Int',
'Days' => 'MultiEnum(array("Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"))',
'Price' => 'Currency'
);
static $has_one = array(
'Level' => 'Level',
'Session' => 'ProgramSession',
'Program' => 'Program'
);
}
When I use the CSV import function as visible below in the bottom left corner:
It seems to work, except that it create duplicates of the Program DataObject, as you can see here:
There should only be one instance each of Mighty Mights and Advanced TRAC. My question is, how do I use CSV import without duplicating relations?
For reference here is the spreadsheet I'm using to export CSVs https://docs.google.com/spreadsheets/d/1Qn6nNHmkQFfNm1Y-CQhTI2-fDiN-rFqeJlv8WSmbDTs/edit?usp=sharing
Many thanks :)
Justin
P.S. - I should also mention I've attempted to extend CsvBulkLoader for ProgramClass, as demonstrated in the Silverstripe Developer Guides, but with no luck.