Jump to:

3461 Posts in 1065 Topics by 740 members

Data Model Questions

SilverStripe Forums » Data Model Questions » Populate Data directly

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

Page: 1
Go to End
Author Topic: 1319 Views
  • CraftsMan
    Avatar
    Community Member
    35 Posts

    Populate Data directly Link to this post

    Hoping someone can help

    I am using ModelAdmin to manage custom DataObjects. I have used a script to directly populate the tables (add additional) with necessary data ( as I have large volume of data to be fed into the site ).

    All seems ok when I review the tables, however when I use the ModelAdmin interface to list them it only lists the original items ( added via cms interface ) and not what I have added direclty.

    Thanks

  • PhilipSchweiger
    Avatar
    Community Member
    2 Posts

    Re: Populate Data directly Link to this post

    Have you run the dev/build (as in, go to the url yoursite/dev/build)? After you make changes to the underlying code, dev/build will update DB tables.

    Going the other way (from new date to updating views), be sure to flush cache (e.g yoursite/?flush=1)

    Also, if you have uploaded any files directly, you will need to go to the Files and Images section of the CMS and click the "Look for new files" button to let SS know about your new files.

  • CraftsMan
    Avatar
    Community Member
    35 Posts

    Re: Populate Data directly Link to this post

    thanks for your feedback. yes I have cleared the cache using flush, done the rebuild and also cleared the silverstripe cache folder completely.

    Whats interesting is that if I add an item via the CMS interface after data import via script, then Add button generates an errors. However when I revisit the full list, it shows an entry from what I had imported via script.

    To clarify that a bit furtehr, if I had 5 items before script import and the import added 3 items, then it will only show the original 5 items. When I add the 6th item via cms, it shows the first item from the imported data insstead...

    A thought:
    Is it possible, SS might be keeping the last used incremental value somewhere which is updated when adding via CMS?

  • CraftsMan
    Avatar
    Community Member
    35 Posts

    Re: Populate Data directly Link to this post

    I have solved my problem. The issue was with the way my unique ID was being created. To elaborate a bit more for anyone else attempting to do the same.

    My goal was to pull data from an existing SS site for specific DataObjects only. These DO also had has_many relations. Since the db I was migrating to already contains data ( and potentially duplicate ids if attempted to migrate as is ), I had to generate the Ids myself.

    Both my main Object and its has_many objects is extended of a custom DO to use common methods. What was key for me is in understanding that SS kept uniqu id at the custom DO level.

    I chose to use custom script as the schema was the same and my attempt at exploring the use of CsvBulkLoader with has_many came up futile.

  • PhilipSchweiger
    Avatar
    Community Member
    2 Posts

    Re: Populate Data directly Link to this post

    Thanks for posting your solution!

    1319 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.