Developer forum

Forum » Development » Ecom tags not working in Razor View

Ecom tags not working in Razor View

Bo Leanderson
Reply

Hello everyone,

I have a question regarding the template tags for Razor. I have been looking in the documentation
for retrieving the @GetString("Ecom:Product.VariantID"), as well as  @GetInteger("Ecom:Product.VariantCount")
in the *.cshtml view. I also tried with @GetValue as well but I am getting nothing.

It works for @GetString("Ecom:Product.Name") and @GetValue("Ecom:Product.Number") but the variants,
@GetString("Ecom:Product.VariantID") are not working.
I don't know if there's something else I have forgotten or left out.


Replies

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

What do you get back from @TemplateTags()? Could it be that ID has changed to Id (i.e. VariantId); I know that has happened to some other tags.

Imar

 
Dimitrij Jazel
Reply

Hello Bo,

1st off you should try adding @TempalteTags() as Imar suggests. And see if your desired tag is beying generated at all. But be sure to add it exactly at that place, where you want your tag to apear. It depends where you add the tag!

2nd, Where exactly are you trying to call "@GetString("Ecom:Product.VariantID") " ? Could you explain where are you trying to call this tag?

Make sure you are calling it in correct place.

For example: if you are trying to call VariandID tag from Master template, or outside of Products loop in Catalog page, then you will have hard time getting this tag.

 

/Dmitrij

 

 
Bo Leanderson
Reply

Thank you for the responses. I have added TemplateTags() as suggested. All values are returned as intended except for VariantCount, which is 0.

I'm trying to call this at the end of the *.cshtml. I have declared it in the top of the page, however but I am trying to call it at the end of the page. It's not calling a Master template, but rather in a product detail template. And in that detail template I wanted to get all variantIDs for other variations of the product.

 
Dimitrij Jazel
Reply
This post has been marked as an answer

I just checked one of the templates I have.

You also need to make sure you are in the loop aswell.

Here is a code example:

@{

foreach (LoopItem i in GetLoop("VariantCombinations"))
{
<p>@i.TemplateTags()</p>
}

foreach (LoopItem i2 in GetLoop("VariantGroups"))
{
<p>@i2.TemplateTags()</p>
}

}

 

More info on DW loops:

https://github.com/dynamicweb/razor/wiki/From-Dynamicweb-HTML-to-Razor#loops

 

Hope this helps.

 

 

 

Votes for this answer: 3
 
Bo Leanderson
Reply

Thank you. I was not inside the loop. Thanks to your example, things work as I want. Thanks a lot, both of you!

 

You must be logged in to post in the forum