Import data with group field linked to another content type

I am migrating from another CMS and would like to import all my data to prismic.

I have an audioTrack content type which has a group field which has a content relationship and allows people to link to multiple genre content type.

The AudioTrack has this group field:

"genres" : {
  "type" : "Group",
  "config" : {
    "fields" : {
      "genre" : {
        "type" : "Link",
        "config" : {
          "select" : "document",
          "customtypes" : [ "genre" ],
          "label" : "Genre",
          "placeholder" : "Select a genre"
        }
      }
    },
    "label" : "Genres"
  }
},

When I am importing the data for an audio track how do I link it to a genre that I have already imported into Prismic CMS?

Any suggestions or better ways of doing this import are welcome.

Thanks

1 Like

If I understand correctly, in your prismic /documents, you will have ‘Audio track’ types, and ‘Genre’ types?

If so, linking genres using the document link as you have suggested should work fine.

Hi Peter,

Welcome to the community!

This is as @marcellothearcane suggests you’ll need add ‘genre’ document link in the ‘audiotrack’ document in your Prismic repo.

Then you can export an example of this document to see what the link should look like in the import then follow that structure for the rest of the import files.

I think all you need is the document ID, but the best way to check is with the test export.

What is your exact use case here, what are you trying to build?

Thanks.

Thanks for your reply @marcellothearcane @Phil. I appreciate it.

I am interested in how to import the content into Prismic.

I create a new new_jazz_genre.json add this to a zip file and then upload to prismic.

{
  "name": "Jazz",
  "type": "genre",
  "tags": [
"genre"
  ],
  "lang": "en-gb"
}

I create a new_jazzTrack1_audioTrack.json which needs to use the genre jazz which i just uploaded to Prismic.

{
  "title": "My track title",
  "genres": [
    {
      "genre": {
        "id": "_________JAZZ_GENRE_ID_____________",
        "type": "genre",
        "tags": [
          "genre"
        ],
        "slug": "jazz-baroque-jazz",
        "lang": "en-gb",
        "link_type": "Document",
        "isBroken": false
      }
    },
  ],
}

Is there an easy way to get the JAZZ_GENRE_ID(see code above) from Prismic. Also, a track can have multiple genres.

I have an idea about how to do this but I would like to know if there is an easy way to do this or if anyone has done this before, to provide some tips?

I will be migrating over 6000 entries from Contentful CMS and importing them into Prismic so I need to get this right the first time. :slight_smile:

I plan to do a test with just one track and see what happens so just looking for guidance.

Hi @peter,

I'm really sorry that we never got back to you on this, this got lost in the backlog. We've recently implemented a new thread tracking process so this doesn't happen again and this is how we've come across this again.

I know it's very late, but you would be able to find the id of the doc JAZZ GENRE document by using the API Browser:

You will then need to run a script on your side to match the Jazz Genres to the Jazz Genre ID from the response and replace these in your JSON files. Unfortunately I don't have any examples of what this might look like.

Sorry again if this is all too late.

Thanks.

This issue has been closed due to inactivity. Flag to reopen.