Copied to clipboard

Flag this post as spam?

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


  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Jul 10, 2013 @ 13:36
    Ismail Mayat
    0

    Latest version with MNTP

    Hello,

    I am using umbrco 6.1.2 and latest version of cmsimport. I have a spreadsheet with 100 products each product has features. I have imported list of each feature using cms import. My product has mntp pickers for each feature the values are stored as csv and you can only have one value.  I have imported small subset of products however the features do not map so i just get empty value for mntp fields.  I thought latest cmsimport supported mntp? Or do i need to write a field adaptor?  

    Regards

    Ismail

  • Richard Soeteman 4046 posts 12899 karma points MVP 2x
    Jul 11, 2013 @ 08:26
    Richard Soeteman
    1

    Hi Ismail,

    I know you find the answer already but a quick reply for future reads.

    MNTP is supported for media indeed in CMSImport.In your case you are using normal content references so you need to write a FieldAdapter to achieve this goal.

    Thanks,

    Richard

     

  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Jul 11, 2013 @ 09:50
    Ismail Mayat
    1

    Richard,

    Yup some code below for anyone interested need to ensure that all the pages that referenced via mntp are published:

    public class MntpAdapter : IFieldAdapter

        {

            private static readonly Dictionary<string,int> LookUp = new Dictionary<string, int>();

     

            public MntpAdapter()

            {

                if (LookUp.Count == 0)

                {

                    LookUp.Add("MNTP Chemical resistance picker (1,1)",1066);

                    LookUp.Add("MNTP Fabric Picker (1,1)", 1127);

                    LookUp.Add("MNTP Max Temp picker (1,1)", 1063);

                    LookUp.Add("MNTP Min Temp picker (1,1)", 1060);

                    LookUp.Add("MNTP Polymer picker (1,1)", 1126);

                    LookUp.Add("MNTP Tensile Strength (1,1)", 1074);

                    LookUp.Add("MNTP Thickness picker (1,1)", 1057);

                    LookUp.Add("MNTP Weight picker (1,1)", 1054);

     

                    LogHelper.Info(typeof(MntpAdapter), () => "initialised lookup dictionary for field adapter");

                }

            }

     

            public Guid DataTypeId

            {

                get { return new Guid("7e062c13-7c41-4ad9-b389-41d88aeef87c"); } //guid of mntp type that all my datatypes are based on

            }

     

            public object Parse(object value, umbraco.cms.businesslogic.property.Property property, FieldAdapterOptions fieldAdapterOptions)

            {

                if (LookUp.ContainsKey(property.PropertyType.DataTypeDefinition.Text))

                {

                    try

                    {

                        value = GetLookUpValue(LookUp[property.PropertyType.DataTypeDefinition.Text], value.ToString(),

                                               property.PropertyType.DataTypeDefinition.Text);

                    }

                    catch (Exception ex)

                    {

                        LogHelper.Error(typeof(MntpAdapter), "doing lookup " + ex.ToString(), ex);

                    }

                }

     

                return value;

            }

     

            /// <summary>

            /// translate the option to previously imported data and get id

            /// so mntp will work

            /// </summary>

            /// <param name="lookUpNodeId"></param>

            /// <param name="value"></param>

            /// <param name="property"></param>

            /// <returns></returns>

            private string GetLookUpValue(int lookUpNodeId, string value,string property)

            {

                string propertyValue = value;

     

                LogHelper.Info(typeof(MntpAdapter), () => string.Format("doing lookup nodeid {0} in value {1}", lookUpNodeId, propertyValue));

     

                var node = uQuery.GetNode(lookUpNodeId).ChildrenAsList.FirstOrDefault(n => n.Name.ToLower() == value.ToLower());

     

                if (node != null && !string.IsNullOrEmpty(node.Name))

                {

                    value = node.Id.ToString();

                }

                else

                {

                    LogHelper.Info(typeof(MntpAdapter), () => string.Format("no value found doing lookup nodeid {0} in value {1} for property {2}", lookUpNodeId, propertyValue, property));

                    value = string.Empty;

                }

     

                return value;

            }

        }

  • Richard Soeteman 4046 posts 12899 karma points MVP 2x
    Jul 12, 2013 @ 09:07
    Richard Soeteman
    0

    Thanks for sharing!

  • Richard Soeteman 4046 posts 12899 karma points MVP 2x
    Aug 21, 2013 @ 12:58
    Richard Soeteman
    100

    Hi Ismail and others,

    In the 2.4 release of CMSImport. Lookups for MNTP are supported. CMSImport will find the rootnode where to look for items based on the datatype configuration of the Multi node tree picker. When a match is found on Name(not case sensitive), or id it will be mapped to MNTP during import. You can also assign comma separated values during import to map multiple items.

    Hope this helps,

    Richard

  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Aug 21, 2013 @ 13:01
    Ismail Mayat
    1

    Richard,

    That is mint!!! Awesome work.

  • Richard Soeteman 4046 posts 12899 karma points MVP 2x
    Aug 21, 2013 @ 14:07
    Richard Soeteman
    0

    Thanks!

  • Ed Knight 16 posts 99 karma points
    Feb 06, 2014 @ 22:50
    Ed Knight
    0

    Hi Richard,

    We have a MNTP for a collection of people (Contacts). Within that we had an a - z node container for organization. Is there a way upon import to look inside each of those node conatiners for the actual node value? Right now, it does not match b/c it is only look at the level immediately below the "Collection Of People" which is essentially the a - z node containers.

    Example:

    - Contacts

      - A

        - Adam

        - Alice

    - B

    - C

    - ...etc.

    Trying to get a match on Adam and Alice.

    Thanks,

    Ed

  • Richard Soeteman 4046 posts 12899 karma points MVP 2x
    Feb 06, 2014 @ 22:56
    Richard Soeteman
    0

    Hi Ed,

    I've fixed this last week for a client who used filters. Release is not fully tested yet therefore it's not yet available. Care to test? If so mail me please [email protected].

    Thanks,

    Richard

  • Ed Knight 16 posts 99 karma points
    Feb 06, 2014 @ 23:11
    Ed Knight
    0

    Awesome - Thanks Richard. Email sent.

  • Filipe Neves 8 posts 28 karma points
    May 07, 2014 @ 14:54
    Filipe Neves
    0

    Hi Richard

    Is the lookup functionality working in Umbraco 7 in CMSImport 2.5.1? 
    I believe I have everything correctly configured. I have some MultiNodeTreePickers on a content I'm importing and all mapped properties are imported except those which are MNTPs. The datasource contains values which exist in the content tree in the MNTP Node Type. I can't seem to find what I'm doing wrong. Can you help please?

    Thanks in advance

  • Richard Soeteman 4046 posts 12899 karma points MVP 2x
    May 08, 2014 @ 08:10
    Richard Soeteman
    0

    Hi Philipe,

    MNTP Node Type should work as expected. But for V7 there are a few changes. Can you share how you configured MNTP Then I can reproduce and fix the issue.

    Thanks,

    Richard

  • Filipe Neves 8 posts 28 karma points
    May 08, 2014 @ 12:01
    Filipe Neves
    0

    Hi Richard

    Thanks for your reply. My MNTP configuration is pretty straightforward:

    Property Editor:
    Multinode Treepicker

    Node type:
    Content
    I've choosen a root node using the content tree, not xpath. 

    Filter: 
    None

    Minimum/maximum number of items:
    None

    Thanks

    Filipe 

     

  • Filipe Neves 8 posts 28 karma points
    May 12, 2014 @ 15:52
    Filipe Neves
    0

    I eventually got a workaround using a FieldProvider.

     

  • Richard Soeteman 4046 posts 12899 karma points MVP 2x
    May 12, 2014 @ 15:56
    Richard Soeteman
    0

    Working on it now. Seems that there was a new MNTP where I thought the other picker was already multi node. Sorry for the confusion it will be in the next version tho.

Please Sign in or register to post replies

Write your reply to:

Draft