I have made a folder (node) containing nodes of brands. Each brand doc type have a brandName property (text string). I have extended my product doc type with a MNTP called "brandPicker".
On my product view (view.cshtml) I want to get the "brandName" from the selected node in my MNTP. Second, if the "brandName" is null, I want to retreive the node name instead.
I can only get the nodeId from the selected node by returning: string brand =TC.GetPropertyValue(storeId, mainProduct, "brandPicker");
I installed Tea Commerce starterkit and even upgraded Umbraco manually to 6.1.6, but the namespace TC doesn't contain the properties "HasProperty" and "HasValue". Furthermore the namespace "Umbraco" can't find "TypedContent".
The only property properties I can grab from TC is "AddOrUpdateOrderProperty", "GetPropertyValue" and "GetXmlPropertyValue".
First I check if the current node contains a property called "brandPicker" and if the property has a value. If so, I get the value (id of the node) and create a new DynamicNode with it.
[code]DynamicNode currentPage = Model; int brandPickerId = 0; if (currentPage.HasProperty("brandPicker") && currentPage.HasValue("brandPicker")) { brandPickerId = int.Parse(currentPage.GetPropertyValue("brandPicker")); } var brand = new DynamicNode(brandPickerId); [/code]
Second I check if the DynamicNode returned an Id and if has a propertyValue "brandName" If so, I get the PropertyValue "brandName" from that node. If not, I simply return the name of the node.
MNTP GetPropertyValue
I have made a folder (node) containing nodes of brands. Each brand doc type have a brandName property (text string).
I have extended my product doc type with a MNTP called "brandPicker".
On my product view (view.cshtml) I want to get the "brandName" from the selected node in my MNTP.
Second, if the "brandName" is null, I want to retreive the node name instead.
I can only get the nodeId from the selected node by returning: string brand = TC.GetPropertyValue(storeId, mainProduct, "brandPicker");
Can anyone please help me?
Hi Eqeek,
Welcome to Umbraco Forum.
If you are using version 6 then you could do this:
Cheers
Ali
Hi Ali,
Thanks for your answer.
I installed Tea Commerce starterkit and even upgraded Umbraco manually to 6.1.6, but the namespace TC doesn't contain the properties "HasProperty" and "HasValue". Furthermore the namespace "Umbraco" can't find "TypedContent".
The only property properties I can grab from TC is "AddOrUpdateOrderProperty", "GetPropertyValue" and "GetXmlPropertyValue".
I finally solved it.
First I check if the current node contains a property called "brandPicker" and if the property has a value. If so, I get the value (id of the node) and create a new DynamicNode with it.
[code]DynamicNode currentPage = Model;
int brandPickerId = 0;
if (currentPage.HasProperty("brandPicker") && currentPage.HasValue("brandPicker"))
{
brandPickerId = int.Parse(currentPage.GetPropertyValue("brandPicker"));
}
var brand = new DynamicNode(brandPickerId);
[/code]
Second I check if the DynamicNode returned an Id and if has a propertyValue "brandName" If so, I get the PropertyValue "brandName" from that node. If not, I simply return the name of the node.
[code]@if (brand.Id != 0 && brand.HasValue("brandName"))
{
@brand.GetPropertyValue("brandName")
}
else
{
@brand.Name
}
[/code]
is working on a reply...