Copied to clipboard

Flag this post as spam?

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


  • Scott Meikle 28 posts 228 karma points
    Jan 11, 2021 @ 16:32
    Scott Meikle
    0

    VendrApi GetProduct with IPublishedElement

    Hello,

    Can I just clarify whether, out of the box, Vendr allows you to define your product data within block types ?

    I am having a play around and have a block type set up with the appropriate Vendr product detail properties but my call in the partial view to link up the element as a product returns a null when I pass the Key of the relevant IPublishedElement underlying my block type to the Vendr API GetProduct method, e.g.

    IProductSnapshot vendrProduct = VendrApi.Instance.GetProduct(myPublishedElement.Key.ToString());
    

    In the above example, the vendrProduct is always returned as null.

    It's no great pain if this approach is not do-able as I can easily change tack and go down the more conventional product node route to get things going but it would be nice to know if it was actually possible in the first place.

    Kind regards,

    Scott

  • Matt Brailsford 4124 posts 22215 karma points MVP 9x c-trib
    Jan 11, 2021 @ 17:10
    Matt Brailsford
    100

    Hi Scott,

    OTB no, Vendr wouldn’t be able to extract product data from a block node. This is because the default ProductInformationExtractor only knows how to grab data from the true node. You could implement your own extractor to work with blocks, but you’d potentially hit a few gotchas.

    Generally the extractor needs to be able to get data given a product reference but there is no way to get directly to a block from its key. You’d need to know the true node key too. You could get round this by using a custom product reference that combines the two keys and then split them in the extractor, it’s just a bit messy.

    There are likely other areas that would expect to exist at the node level too, such as the stock property editor.

    Ultimately, unless you want to override some behaviours, it’s best to store product data on the actual node.

    Matt

  • Scott Meikle 28 posts 228 karma points
    Jan 11, 2021 @ 17:21
    Scott Meikle
    0

    Thanks Matt, I did feel that might be the case. Like you suggest, I am a bit wary of disappearing too far off-piste for this as it would doubtless open a can of worms further down the line so I will crack on with using full nodes for product data.

    Scott

Please Sign in or register to post replies

Write your reply to:

Draft