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.
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.
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.
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.
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.
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
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
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
is working on a reply...