Copied to clipboard

Flag this post as spam?

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


  • Edgar Rasquin 326 posts 925 karma points
    Mar 11, 2021 @ 11:28
    Edgar Rasquin
    0

    Import Price Value

    Hi there,

    I have set up my Vendr Store following the instructions from Paul Seals Tutorial:

    How to build an eCommerce site in Umbraco using Vendr

    Now I tried to import Products using the Umbraco Packages: CMSIMPORT and a second, fairly new package, CSV Import

    All values are imported apart from the Price (decimal)

    I have tried to change the format in my CSV import file to all sort of formats without success.

    There is no error. The Price field just stays empty.

    Any ideas?

  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    Mar 11, 2021 @ 12:15
    Matt Brailsford
    0

    Hi Edgar,

    The price property is using a Vendr property editor with a specific data structure and so the importers will likely need to know how to import those values. With CMS Import I think that can be handled via a custom FieldAdapter which would contain the logic to convert the single csv value into the specific data structure.

    The data structure of a price field is:

    {
        "40603204-1990-4b33-8402-fe289b917d38": 2.51,
        "665f821f-ecf4-4d51-8939-f2c359aecd35": 1.57
    }
    

    Here, the Guid object keys are the ID's of Vendr Currencies. In your FieldAdapter you could lookup whatever is the default currency for a store and just assign the value to that currency.

    You'll probably need to ask in the CMS Import form for more info on how to implement a FieldAdapter.

  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    Mar 11, 2021 @ 12:23
    Matt Brailsford
    0

    Ok, just checked the CMS Import docs here https://soetemansoftware.nl/media/60883/cmsimport-manual.pdf and it looks like it's now called a FieldProvider. You can find documentation on how to implement one yourself in page 25.

    Speaking with Richard, we may look to create a Vendr add-on package to encapsulate all of this as it would be really handy for others too, however this won't be available immediately so a custom FieldProvider would be the only option currently.

  • Edgar Rasquin 326 posts 925 karma points
    Mar 11, 2021 @ 13:40
    Edgar Rasquin
    0

    Hi Matt,

    thanks for your reply.

    I have now tried to set up the class like so:

    using CMSImport.Extensions.Providers.FieldProviders;
    using CMSImport.Extensions.Providers.ImportProviders;
    using Umbraco.Core.Services;
    
    namespace CampusShop.Core.Controllers
    {
    public class CurrencyFieldProvider :IFieldProvider
    {
        private readonly IContentService _contentService;
        public CurrencyFieldProvider(IContentService contentService)
        {
            _contentService = contentService;
        }
    
        public object Parse(object value, ImportPropertyInfo property, FieldProviderOptions fieldProviderOptions)
        { 
            //EXAMPLE CODE PLEASE
            return "6FD40872-83A8-473E-9DE4-F1305049F8D9": value;
        }
    }
    
    }
    

    Unfortunately I have no idea how to handle the bit where it says: //EXAMPLE CODE PLEASE

    Could you point in the right direction please?

    Thank you

  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    Mar 11, 2021 @ 14:10
    Matt Brailsford
    1

    Hi Edgar,

    I'm not 100% sure myself as I haven't looked into how CMS Import works but my guess is that it might need the value returning in the expected raw format, which for the Vendr Price property will be a JSON serialized string of the data structure I gave earlier so it might need to be something like

    var price = Decimal.Parse(value.AsString());
    var data = new Dictionary<string, decimal> {
         { "6FD40872-83A8-473E-9DE4-F1305049F8D9", price }
    };    
    return JsonConvert.SerializeObject(data);
    

    Given the known data structure, it might be best asking on the CMS Import forums about specific implementation as like I say, I haven't done this myself yet, as I'm just repeating their docs to you atm.

    Matt

  • Edgar Rasquin 326 posts 925 karma points
    Mar 11, 2021 @ 16:35
    Edgar Rasquin
    0

    Thank you Matt.

    I have now shifted the issue to the CMS Import forum.

    Hopefully someone can help out.

  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    Mar 11, 2021 @ 16:49
    Matt Brailsford
    0

    No problem

    I've subscribed to the other topic so I'll follow along and see if I can't offer any input if there is something Vendr specific required.

    Matt

Please Sign in or register to post replies

Write your reply to:

Draft