Developer forum

Forum » Development » Reusing productlist renderer

Reusing productlist renderer


Reply

Hi,

I'm creating a search module that searches in eCom products, in a very specific way, with lots of search rules and more, but the result of my search is a "simple" ProductCollection.

Is it possible to use the Renderer class to get my result listed exactly like the product list template?

I'm looking for a way to skip around creating my own paging functionality, and since the product list has all the features i need, it would be ideal to use it as the base for my result output.

I tried this, but the output is missing a lot of tags:

Dynamicweb.eCommerce.Frontend.Renderer r = new Dynamicweb.eCommerce.Frontend.Renderer();
Dynamicweb.Templatev2.Template t = new Dynamicweb.Templatev2.Template( "TekniskSoegning/List.html" );

Dynamicweb.eCommerce.Products.ProductCollection prodList = new Dynamicweb.eCommerce.Products.ProductCollection();
prodList.Load( "SELECT TOP 10 * FROM EcomProducts" );
     
r.RenderProducts( prodList, t, "Results" );

 return t.Output();

Has anyone done this before? Is it possible?

Regards
 Martin


Replies

 
Reply
Hi Martin,
I think is possible to reuse "RenderProducts". But you need add ParagraphSetting in  your "Renderer" instance.
 
Reply
Hi,

I tried your suggestion and did this:
Dynamicweb.Templatev2.Template t = new Dynamicweb.Templatev2.Template( "TekniskSoegning/List.html" );
Dynamicweb.eCommerce.Frontend.Renderer r = new Dynamicweb.eCommerce.Frontend.Renderer();
r.ParagraphSettings = new Dynamicweb.eCommerce.Frontend.ProductCatalogSettings(1); // Paragraph 1 contains a EcomCatalog
r.RenderProducts( prodList, t );

But my output does not use my settings for pagesize and more.

I get these templatags out, but ever if my Pagesize is set to 15, all products are rendered and Next/PrevPage is empty:

0 Copy tag to clipboard 1 1
1 Copy tag to clipboard 23 " style="display:none;"
2 Copy tag to clipboard 0  
3 Copy tag to clipboard 1 0
4 Copy tag to clipboard 2 15
5 Copy tag to clipboard 23 " style="display:none;"
6 Copy tag to clipboard 0  
7 Copy tag to clipboard 1 0
8 Copy tag to clipboard 0  
9 Copy tag to clipboard 0  
10 Copy tag to clipboard 1 0
11 Copy tag to clipboard 1 0
12 Copy tag to clipboard 0  
13 Copy tag to clipboard 74897 Vil søgning AnvendelseFilter Bolig (19)
14 Copy tag to clipboard 0  
15 Copy tag to clipboard 1  
16 Copy tag to clipboard 0  
17 Copy tag to clipboard 0

Got any other ideas as to what might be missing?
   
Nicolai Høeg Pedersen
Reply
This is how DW does it - think you are also missing the pageview instance:

Private renderer As Renderer
Private settings As ProductCatalogSettings
settings = New ProductCatalogSettings(Properties)

renderer = New Renderer(Pageview, ParagraphRow)
renderer.ParagraphSettings = settings

Return renderer.RenderProducts(pageProductColl)

In the Renderer constructor there is a paragraphrow .- that should not be needed.
 
Martin Nielsen
Reply
Hi Nicolai,

I've tried adding pageview to the renderer, but my pagesize and other settings still isn't applied to my output.

My code looks like this:
SearchResult resultat = GetResult( searchwords, searchLikeThis );
// List of products
Dynamicweb.eCommerce.Products.ProductCollection prodList = resultat.Products;
Dynamicweb.eCommerce.Frontend.Renderer r = new Dynamicweb.eCommerce.Frontend.Renderer( base.Pageview );
// Paragraph 1, is an ecomCatalog on a different page, that has the settings i want to use.
r.ParagraphSettings = new Dynamicweb.eCommerce.Frontend.ProductCatalogSettings( 1 );
r.RenderProducts( prodList, t );

Got any other ideas?

Regards
 Martin

 

You must be logged in to post in the forum