Copied to clipboard

Flag this post as spam?

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


  • Kyle Eck 130 posts 280 karma points
    Mar 25, 2022 @ 20:03
    Kyle Eck
    0

    Set Variant Price Programmatically

    Matt,

    I am working on writing a simple Price updater for the products within Vendr.

    Getting and updating the parent product Price is easy and already completed.

    Is there a way to get the product price for a complex variant?

    I can do something like this:

    _vendrApi.GetProduct(store, produductRef, productVariantRef, language)
    

    And get the specific variant I want to work with but is there any way to say SetValue("price", MyValue) for the variant specifically.

    Ideally im looking for how I can make a variant mutable and not just read only per se.

    I was hoping it would be treated just like a node and you could set such things like this but I am having no luck at the moment...

    Short of generating the entire json string for all of the variants on the parent node (which I really don't want to have to go through lol) im not finding another way

    Thanks.

  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    Mar 28, 2022 @ 08:15
    Matt Brailsford
    0

    Hi Kyle,

    Unfortunately not. The variants property editor is based off Umbraco's block list editor and because of this ultimately all the variants data is stored within one field on the parent node. As such, this does mean you'll have to deal with them as an entire block and save it back to the parent and then save the parent.

    Hopefully this will change in future as we ensured it was based on the block lists editor as there was talk in HQ about making these be persisted as nodes at some point. When that happens, then you may be able to deal with them directly, but for now, you'll have to work with them as a whole.

  • Kyle Eck 130 posts 280 karma points
    Mar 28, 2022 @ 10:41
    Kyle Eck
    0

    Matt,

    I was leaning that way and prepared to go down the non editable road but had to make sure I wasn’t missing something.

    All the best, Kyle

Please Sign in or register to post replies

Write your reply to:

Draft