2
votes

I am attempting to import data into Orchard CMS. I have a custom type, made up of parts and fields, and I am using the ImportExport module. I have exported some data from Orchard to ensure the XML schema is correct, but when importing, the only field that seems to be populating is the TitlePart Title. I have randomly generated a GUID for the identifier of each record. Orchard 1.4, ImportExport 1.4.

Example of one item of data:

<Orchard>
  <Recipe>
    <Name>Data Import</Name>
    <Author>myaccount</Author>
  </Recipe>
  <Data>
    <OurPropertiesDivision Id="/Identifier=94eff3237c714f98b021905c33d25ea9" Status="Published">
      <LinkField.Link Text="This is a link" Url="http://stackoverflow.com" />
      <MediaPickerField.ImageOne Url="~/test.jpg" Width="100" Height="100" />
      <MediaPickerField.ImageTwo Url="~/test2.jpg" Width="100" Height="100" />
      <MediaPickerField.ImageThree Url="~/test3.jpg" Width="100" Height="100" />
      <TitlePart Title="Test Title" />
      <CommonPart Owner="/User.UserName=myaccount" CreatedUtc="2012-04-04T23:03:39Z" PublishedUtc="2012-04-04T23:03:39Z" ModifiedUtc="2012-04-04T23:03:39Z" />
      <IdentityPart Identifier="94eff3237c714f98b021905c33d25ea9" />
    </OurPropertiesDivision>
  </Data>
</Orchard>

This results in the following when looking at the imported entry:

Content list:

Orchard Content List

Edit screen:

Orchard Edit Screen

The only field that is making it through the import is the TitlePart. How can I make this work in a way that I can bulk insert any type of field or part with data? I would also like to capture the Container for the Containable part.

EDIT: Adding content type metadata

<?xml version="1.0"?>
<!--Exported from Orchard-->
-<Orchard>
  -<Recipe>
    <Name>Generated by Orchard.ImportExport</Name>
    <Author>myaccount</Author>
  </Recipe> -<Metadata>
    -<Types>
      -<OurPropertiesDivision DisplayName="Our Properties - Division" ContentTypeSettings.Draftable="True" ContentTypeSettings.Creatable="True">
        <CommonPart DateEditorSettings.ShowDateEditor="False" OwnerEditorSettings.ShowOwnerEditor="False"/>
        <TitlePart/>
        <OurPropertiesDivision/>
        <ContainablePart/>
        <IdentityPart/>
      </OurPropertiesDivision>
    </Types> -<Parts>
      <CommonPart ContentPartSettings.Attachable="True"/> <TitlePart ContentPartSettings.Attachable="True"/> -<OurPropertiesDivision ContentPartSettings.Attachable="True">
        <ImageOne.MediaPickerField DisplayName="Image One" MediaPickerFieldSettings.Required="False" HtmlFieldSettings.FlavorDefault="html"/>
        <ImageTwo.MediaPickerField DisplayName="Image Two" MediaPickerFieldSettings.Required="False" HtmlFieldSettings.FlavorDefault="html"/>
        <ImageThree.MediaPickerField DisplayName="Image Three" MediaPickerFieldSettings.Required="False" HtmlFieldSettings.FlavorDefault="html"/>
        <Content.HtmlField DisplayName="Content" HtmlFieldSettings.FlavorDefault="html"/>
        <Link.LinkField DisplayName="Link" HtmlFieldSettings.FlavorDefault="html" LinkFieldSettings.LinkTextMode="Required" LinkFieldSettings.TargetMode="NewWindow" LinkFieldSettings.Required="True"/>
      </OurPropertiesDivision> <ContainablePart ContentPartSettings.Attachable="True"/> <IdentityPart ContentPartSettings.Attachable="True"/>
    </Parts>
  </Metadata>
</Orchard>
1
There have sometimes been issues where importing puts data into the db, but under different versions for the content item. So the latest or published (can't remember which) version of the content Item (which is displayed in the dashboard) doesn't have data. Can you check in the db to see if this is the case?Giscard Biamby
I have never touched the Orchard database directly before, but I am noticing that in the Orchard_Framework_ContentItemRecord table, the imports are the only rows that contain data inside of the Data column, and they have all of the fields from the import. All of the other rows seem to store their data inside of the Orchard_Framework_ContentItemVersionRecord table. Is this a bug with the Import feature not taking versioning into account, or some other issue?Carson
It might be. I experienced a similar bug once before, but it was fixed. Did you define this content item via the Dashboard, or through code (i.e., in Migrations.cs)? If you did it through code can you paste the code? If not can you paste the metadata for the Content Item definition? You can get this through export, check the Metadata checkbox.Giscard Biamby
@GiscardBiamby I have added the meta data from the content type that was created in the dashboard. Due to time constraints, I am manually importing the data directly into SQL server, but it would be good to find out what's causing this issue.Carson
I don't know what's wrong off the top of my head. Hopefully someone else can answer this. You might also want to file a bug on the orchard.codeplex.com site.Giscard Biamby

1 Answers

0
votes

I ended up analyzing the database inserts generated by the admin, and manually importing the data in SQL.