Developer forum

Forum » Templates » Hot to get Ecom custom product fields in razor templates

Hot to get Ecom custom product fields in razor templates

Finn Frost
Reply

How do I get the values of the custom product fields within razor templates?

I have created a custom product field("ProductCustomStartDate" of type DateTime), that i need to display on a product list page.

In my template i would expect something like this, but this doesn't seem to work.

foreach (LoopItem i in GetLoop("Products")){

       foreach (LoopItem cf in GetLoop("CustomFields")){
    		<text>@cf.GetValue("CustomField.ProductCustomStartDate")</text>
    	}

}

Can anybody please help?


Replies

 
Mikkel Ricky
Reply

You have to use @cf.GetValue("ProductCustomStartDate.Value") (or @cf.GetDate to get a real Date object). However, we're currently having some issues with nested loops in Razor and we're working on a fix.

Best regards,
Mikkel

 

 

You must be logged in to post in the forum