Developer forum

Forum » Development » Using product renderer

Using product renderer

Martin Nielsen
Reply

Hi DW.
   
I'm trying to reuse Dynamicwebs product renderer but i'm getting an ArgumentOutOfRangeException.

My code looks like this:

void doStuff(){
  Dynamicweb.Templatev2.Template t = new Dynamicweb.Templatev2.Template();
  AppendProductTagsToTemplate( ref t, productID, variantID, languageID );
  string test =  t.Output();
}

private void AppendProductTagsToTemplate(ref Dynamicweb.Templatev2.Template template, string productID, string variantID, string Language) {

  Dynamicweb.eCommerce.Products.Product p = new Dynamicweb.eCommerce.Products.Product( productID, variantID, Language );
  Dynamicweb.eCommerce.Frontend.Renderer r = new Dynamicweb.eCommerce.Frontend.Renderer( _pageview, _datarow );
  r.RenderProduct( p, true, template );

}

When i get to t.Output(); i throws my exception.

What's missing?

Regards
 Martin

Replies

 
Morten Bengtson
Reply
Try to use the renderer without the DataRow parameter...
var r = new Dynamicweb.eCommerce.Frontend.Renderer(_pageview);
r.RenderProduct( p, true, template);
 
Martin Nielsen
Reply
 Hi Morten,

I found out that the error wasn't related to the product template but rather that i have <--@DwTemplateTags--> in my template.

With the exact same code this template works:

<--@Ecom:Product.Name-->

This does not:

<--@Ecom:ProductName-->
<--@DwTemplateTags-->


I don't load a template file but rather set the HTML for the template in code. Can this be a problem?
Is Template.Output() dependent on something?

// Martin





 

You must be logged in to post in the forum