Developer forum

Forum » Development » Issue with product fields

Issue with product fields

Bo Leanderson
Reply

Hello,

I'm having an issue with the Ecom:Product:Field.[TagName] in a project we're working on. I checked the documentation for this and tried the following on PromotionProducts.cshtml page:

var kampanj= Model.Item.GetBoolean("Ecom:Product:Field.Kampanj");

This gives the error:

Exception in template (\Designs\Rapido\Paragraph\PromotionProducts.cshtml): System.Exception: A field with the name Ecom:Product:Field.Kampanj does not exist
   at Dynamicweb.Frontend.ItemViewModel.GetField(String systemName)
   at Dynamicweb.Frontend.ItemViewModel.GetBoolean(String systemName)
   at CompiledRazorTemplates.Dynamic.ffbbaddff.Execute()
   at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context)
   at RazorEngine.Templating.TemplateService.Run(ITemplate template, DynamicViewBag viewBag)
   at RazorEngine.Templating.TemplateService.Parse(String razorTemplate, Object model, DynamicViewBag viewBag, String cacheName)
   at RazorEngine.Razor.Parse[T](String razorTemplate, T model, String cacheName)
   at Dynamicweb.Rendering.Template.RenderRazorTemplate()

I created the field in Settings>Ecommerce>Product fields with the FIELD NAME being: Kampanj SYSTEM NAME Kampanj and TEMPLATE TAG: Kampanj and FIELD TYPE: Checkbox

I also tested a field called descriptionShort, which also was not found.

Also, while in the PromotionProducts.cshtml, the razor code for template tags doesn't work, but the HTML code for the template tags works.
Any ideas why this is?


Replies

 
Morten Bengtson Dynamicweb Employee
Morten Bengtson
Reply

Hi Bo,

Model.Item does not contain the product fields. Model.Item is the page/paragraph item - depending on the template and view model you are using.

You need to make sure that the paragraph template renders the output from the product catalog...

<div>@GetString("ParagraphModule")</div>

In order to render the product fields you can do something like this inside the product template...

<div>@GetBoolean("Ecom:Product:Field.Kampanj")</div>

and if you want to render the short description...

<div>@GetString("Ecom:Product.ShortDescription")</div>

You can get an overview of available tags by inserting the following in your razor template...

@TemplateTags()

Best regards,
Morten

 

You must be logged in to post in the forum