This project is read-only.

How to bulk import content items

Topics: Administration
Oct 17, 2014 at 3:02 PM
Hey everyone,

I just did an export of some content items and it looks this:
    <Name>Generated by Orchard.ImportExport</Name>
    <Wijn Id="/alias=Assortiment\/42" Status="Published">
      <TextField.PromotieTekst Text="Bij aankoop van 6 flessen 1 fles gratis" />
      <TextField.Domein Text="Roze bergen" />
      <TextField.Inhoud Text="1,5" />
      <TextField.Aantalflessenperdoos />
      <TextField.Druivensoort Text="cabernet sauvignon" />
      <TextField.Alcoholpercentage Text="13,5" />
      <TextField.Karakteristieken />
      <TextField.Serverenbij Text="ijsjes" />
      <TextField.Herkomst />
      <TextField.Huis />
      <TextField.Serveertemperatuur Text="18" />
      <TextField.Bewaartijd Text="20" />
      <MediaLibraryPickerField.WijnFoto ContentItems="/Identifier=61fb7a0a4761453c842bd9777d50c47e" />
      <BooleanField.Promotie Value="true" />
      <BooleanField.Tijdelijkinvoorraad Value="true" />
      <NumericField.Prijs Value="12" />
      <NumericField.Jaar Value="2008" />
      <TaxonomyField.Dranken Terms="/alias=dranken\/rose" />
      <TaxonomyField.Land Terms="/alias=land\/italie" />
      <BodyPart Text="&lt;p&gt;Ros&amp;eacute; uit Itali&amp;euml;&lt;/p&gt;" />
      <CommonPart Owner="/User.UserName=admin" CreatedUtc="2014-04-16T13:00:08.4856861Z" PublishedUtc="2014-08-11T11:09:00.6041816Z" ModifiedUtc="2014-08-11T11:09:00.4635661Z" />
      <AutoroutePart Alias="Assortiment/42" UseCustomPattern="false" />
      <TitlePart Title="Rose Italie" />
Now, should my import file look exactly like this?
Can I leave out the id, autoroutepart and commonpart? Also for the MediaLibraryPickerField.WijnFoto, can I supply a path and picture name?

Kind regards,

Oct 18, 2014 at 1:56 AM
Essentially, yes: when you export from Orchard, the generated XML file can be used to import it into another instance.
However there are a few caveats to be aware of:

If something references another content item (by its identifier), that content item with that identifier must either appear before the depending content item, or already be in the database to which you are importing. For example, if you have a widget in your XML file that references its container, which is a Layer content item, that Layer content item must appear before the widget (unless that layer already exists in the target database). In the case of your XML file above, you have a Wijn content item that has a WijnFoto MediaLibraryPickerField, which references a content item with a certain identifier ("/Identifier=61fb7a0a4761453c842bd9777d50c47e"). However, if that media item does not already exist in your target installation, the import session will fail.

I guess you could leave out the AutoroutePart and TitlePart, then your content won't have a title or an alias.
Oct 18, 2014 at 11:14 AM

Tx for your answer, so it's impossible to load an image in the xml file referencing to its path? How can I get the link between the Identifier and the filename?

Also, should i provide an Id? Or will Orchard generate an Id? Last question :) I have a lot of text like Rosé, which contains special characters, will that be a problem? (you can see that in the bodypart text)

Oct 18, 2014 at 10:46 PM
Well, not impossible, but you would have to come up with your own part that serializes a path to an image, and deserialize that. If you want to use the MediaLibraryPickerField, then you also need to export the media items being referenced.

Before answering the other questions, here's a crazy idea: try it out and see what happens. :)
Oct 20, 2014 at 2:08 PM

You're full of crazy ideas!! :)

Well, I can export the Orchard_Framework_ContentItemRecord table, then do a crosscheck with notepad++ or excel to get the identifier with the corresponding image name (I think that would be the easiest :)

Tx again for your answer, I'll give it a go!

Oct 20, 2014 at 7:56 PM
:) Good luck!