Jump to:

22977 Posts in 11806 Topics by 2826 members

General Questions

SilverStripe Forums » General Questions » CsvBulkLoader question

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Page: 1
Go to End
Author Topic: 503 Views
  • Futureweb
    Avatar
    Community Member
    232 Posts

    CsvBulkLoader question Link to this post

    Hi,

    I have a load of surveys, in excel, with 2 columns, question, answer.
    I'm importing this info using the CsvBulkLoader in model admin.

    it imports the individual items (surveyItems) ok, but what I want to do is create a relationship with 'Surveys' and 'SurveyItems'

    Two options as far as I can see:

    Either a kind 'onBeforeImportCSV' function that create the Survey item, then attaches this ID to each item.

    Or, like in the 'Security Area', create a group (or in this case Survey), then there is an 'import' tab on the screen.

    Does anyone have any ideas for how to implement either of these two options?
    Cheers

  • zenmonkey
    Avatar
    Community Member
    524 Posts

    Re: CsvBulkLoader question Link to this post

    You can create custom relationship call backs to create relations with other DataObjects. I often use it to automatically locate and add images when importing product data. SilverStripe is clever in that it will automatically create new relationship items

    http://doc.silverstripe.org/sapphire/en/howto/csv-import

    You will need to to populate your table with both the SurveyItem data and the SurveyData and use dot notation to to map your columns to the right table.

    One caveat, if multiple Surveys have SurveyItems with the same field you're using for a duplicate check it may make more sense to import into Survey and have the bulk loader create the SurveyItem.

    503 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.