Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Paul Spinks 6 posts 97 karma points
    Oct 02, 2020 @ 16:00
    Paul Spinks
    0

    Import data into nested content

    I've purchased CMS Import Pro and like to able to use SQL or CSV to import data into a nested content

    Nested Content 1 Nested Content 2

    How would I able to let's say create Furniture with Cabinet Material Finish of Red?

    They'll be more characteristics at later date.

  • Richard Soeteman 4035 posts 12842 karma points MVP
    Oct 05, 2020 @ 06:09
    Richard Soeteman
    100

    Hi Paul,

    Nested Content and the Grid + Block editor require that you write a FieldProvider or Advanced settings provider for that field. It's so special that you can't create a generic fieldmapper for that.

    Section 9.3 and 9.4 of the Manual describe how you can implement these providers.

    Hope this helps.

    Best,

    Richard

  • Paul Spinks 6 posts 97 karma points
    Oct 05, 2020 @ 22:10
    Paul Spinks
    0

    Got it working using FieldProvider, thank you.

    For anyone else in a similar position to me, you just need serialise the nested content like:

        public object Parse(object value, ImportPropertyInfo property, FieldProviderOptions fieldProviderOptions)
        {
            list.Add(new Dictionary<string, string>()
            {
                {"key", Guid.NewGuid().ToString() },
                {"name", Guid.NewGuid().ToString() },
                {"ncContentTypeAlias", "basin"},
                {"productMaterial","Hello1"},
                {"basinTapHoles","Hello2"},
            });
    
            return JsonConvert.SerializeObject(list);
        }
    

    You'll need to split the string on how you see fit to loop through the nested content or whatever requirements you need. Hopefully helpful to someone.

  • Richard Soeteman 4035 posts 12842 karma points MVP
    Oct 06, 2020 @ 05:51
    Richard Soeteman
    0

    Thanks for Sharing Paul!

  • Chester Campbell 98 posts 209 karma points
    Feb 25, 2021 @ 15:16
    Chester Campbell
    0

    What happens when my destination Umbraco 8 site has multiple Data Types defined using Nested Content?

    For example, let's say I have these two data types:

    1. Banner Ad Picker (Nested Content) consisting of element types: Banner Ad. The document type Banner Ad (alias: bannerAd) has these fields:
      • Label (alias: label) Textstring
      • Title (alias: title) Textstring
      • Image (alias: image) Image Picker (based on Media Picker)
      • Link (alias: link) URL Picker (based on Multi URL Picker)
    2. Gallery Images Picker (Nested Content) consisting of element types: Gallery Image. The document type Gallery Image (alias: galleryImage) has these fields:
      • Title (alias: title) Textstring
      • By Line (alias: byLine) Textstring
      • Image (alias: image) Image Picker (based on Media Picker)
      • Photo Credit (alias: photoCredit) Textstring
      • Body Content (alias: bodyContent) Rich Text Editors

    Both of these Data Types have this Property Editor Alias: Umbraco.NestedContent

    Let's say I'm importing some articles and mapping them to a Document Type Article (alias: article) which has a property Gallery Images (alias: galleryImages). The galleryImages property uses the Gallery Images Picker data type. During the import my custom FieldProvider is selected to map the Gallery Images data but how is it to know whether the destination data type is Banner Ad Picker or Gallery Images Picker? They're both Umbraco.NestedContent.

    I'm guessing the property mapping that is done as part of the import process ... where I say field X in my source is mapped to galleryImages of document type article in the CMS ... is part of the ImportPropertyInfo or FieldProviderOptions params passed into Parse()?

  • Richard Soeteman 4035 posts 12842 karma points MVP
    Feb 26, 2021 @ 07:19
    Richard Soeteman
    0

    Hi Chester,

    You get the PropertyEditorAlias of the property in your FieldProvider and act on that.

    If you inject IMediaImport on the constructor of the FieldProvider you can use

    mediaimport.Import('relativeFileName, imageparentGuid, fileParentGuid, userid,breakwhenfilenotexists)
    

    This will import the media as well.

    Hope this helps,

    Richard

  • Chester Campbell 98 posts 209 karma points
    Feb 26, 2021 @ 15:24
    Chester Campbell
    0

    Thank you. I'll give it a try!

Please Sign in or register to post replies

Write your reply to:

Draft