Copied to clipboard

Flag this post as spam?

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


  • jonas-jaderberg 7 posts 47 karma points
    Jun 02, 2021 @ 09:02
    jonas-jaderberg
    0

    Fallback on Variants

    Hi, I am testing out Vendr and multi variants, looks great by the way. But I am trying to figure out if and how fallback fram variants to parent is working. From the blog post it's says that sku, price should fallback to it's parent. I haven't got that working. Should it work?

    For other properties that I have put in a composition like productName I try to manually fallback to parent node by doing

    var variants = Model.Variant //Get's the list of all variants
    var variant = variants[1].Content;
    var productName = variant.Value<string>("productName",null,null,Fallback.ToAncestors); 
    

    On the last line I got an exception System.NotSupportedException: 'Fallback PublishedValueFallback does not support fallback code '3' at element level.'

    How can I get a property on a variant, not set, to fallback to it's parent?

    Best regards,

    Jonas Jäderberg

  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    Jun 02, 2021 @ 09:09
    Matt Brailsford
    101

    Hi Jonas,

    The "fallback" behavior we mention only occurs within the product adapter when creating a vendr product snapshot, so when you ask for a snapshot of a product variant from Vendr's API, it will attempt to find the details from the variant node and if one isn't present, it will then fall back to the parent node.

    What you have in the code example is pure umbraco property access and unfortunately that doesn't support fallbacks in this way (ie, you can't do this with nested content or any other block list editor either). If you need fallbacks in this type of code, then unfortunately it would need to be manual as far as I am aware.

  • jonas-jaderberg 7 posts 47 karma points
    Jun 02, 2021 @ 10:33
    jonas-jaderberg
    0

    Hi,

    Thanks, for swift response.

    Yes, if I accessed the product via Vendr API e.g. by using variant.AsVendrProduct(parent) It fallbacks to the parent if missing.

    For other cases I will do it manually.

Please Sign in or register to post replies

Write your reply to:

Draft