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.