You should be able to set the price property via Umbraco's content API. You'll need to feed it the expected data formatted for the Price property editor, which needs to be like:
I took a stab at this with not much luck. I suspect it is in the way I am structuring the value object.
I tried the following approaches
// set price
productNode.SetValue(DocumentTypeProperties.BaseVendrProductPrice, new { RootNodes.eVendrCurrenciesUSDNodeKey, price});
and also this passing as a dictionary then tried to pass it as KeyValuePair by getting FirstOrDefault
// set price
Dictionary<string, int> price = new Dictionary<string, int>
{
{ RootNodes.eVendrCurrenciesUSDNodeKey, price}
};
productNode.SetValue(DocumentTypeProperties.BaseVendrProductPrice, price.FirstOrDefault());
RootNodes.eVendrCurrenciesUSDNodeKey holds the GUID of the currency created in the settings section
DocumentTypeProperties.BaseVendrProductPrice holds the alias of the price property on the product document type
I have tried with the price as a decimal as well in these scenarios.
Setting Vendr Product Price Programatically
Hi Matt
Just a quick one here.
How would I go about setting the price property programatcally
Hey Francis,
You should be able to set the price property via Umbraco's content API. You'll need to feed it the expected data formatted for the Price property editor, which needs to be like:
The GUIDs being the ID's of the Currencies and the values being the price for those currencies.
To get a list of Currencies you can get these from the from the Vendr Currency Service
Hope this helps
/Matt
Hi Matt
Thanks for the guidance much appreciated.
I took a stab at this with not much luck. I suspect it is in the way I am structuring the value object.
I tried the following approaches
and also this passing as a dictionary then tried to pass it as KeyValuePair by getting FirstOrDefault
RootNodes.eVendrCurrenciesUSDNodeKey holds the GUID of the currency created in the settings section DocumentTypeProperties.BaseVendrProductPrice holds the alias of the price property on the product document type
I have tried with the price as a decimal as well in these scenarios.
Much appreciated.
Hey Francis,
Have you tried serializing it to a JSON string?
/Matt
Thanks Matt
That did it. Totally forgot about that.
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.