Copied to clipboard

Flag this post as spam?

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


  • Jeremy Newman 18 posts 190 karma points
    Oct 02, 2016 @ 16:49
    Jeremy Newman
    0

    Product Collection Key too long

    I am using the Merchello 2.2.1 and having an issues with getting a product collection from a detached content type.

    I created a doctype with a product collection picker which is set as the extended content type of a product. I am then trying to pull a list of the products from that collection inside a merchello surface controller.

    The value returned from the ProductCollectionPicker should be, I think, the collection key and that should be a GUID.

    The problem is that it is 33 characters instead of 32 and I cannot use it to get a list of products. What am I missing?

    Error: Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).

    MemberProduct is an IProduct

            var extendedContent = MemberProduct.DetachedContents.FirstOrDefault();
            var certCollectionProperty = extendedContent
                    .DetachedDataValues
                    .FirstOrDefault(c => c.Key.ToLowerInvariant().Equals("certifications"));
    
            var certCollectionKey = Guid.Parse(certCollectionProperty.Value);
    
            var certList = MerchelloServices
                .ProductService
                .GetFromCollection(certCollectionKey, 1, int.MaxValue, "Sku", SortDirection.Ascending)
                .Items
                .ToSelectList(p => $"{p.Price.ToString("C")} - {p.Name}", p => p.Sku, SelectListPrompt);
    

    Please ignore the need to refactor FYI - This is not the final code just figuring things out.

  • Jeremy Newman 18 posts 190 karma points
    Oct 02, 2016 @ 18:21
    Jeremy Newman
    100

    Doh! The key value is quoted... completely missed that...

    var certCollectionKey = Guid.Parse(certCollectionProperty.Value.Replace("\"", string.Empty));
    
Please Sign in or register to post replies

Write your reply to:

Draft