Developer forum

Forum » Development » Render product list template

Render product list template


Reply


I’m trying to render a product list template and use the html to send an email (I don’t know if that works)
But at this moment I’m having other problem, the template can’t be rendered.

Here is the code.


 

ProductCollection pcActivos = Product.getActiveProducts();

            ProductCollection pcDesactivar = new ProductCollection();

 

            DataTable dt = new DataTable();

            dt.Load(Dynamicweb.Database.getDataReader(SQL_SELECT_Dias,""));

            int dias = Convert.ToInt32(dt.Rows[0]["dias"].ToString());

            DataTable dtNotificar = new DataTable();

            dtNotificar.Load(Dynamicweb.Database.getDataReader(string.Format(SQL_SELECT_GroupFieldValue, dt.Rows[0]["campoNotificar"].ToString()), ""));

            foreach (Product p in pcActivos)

            {

                if (DateTime.Compare(DateTime.Now, p.Updated.AddDays(dias)) > 0)

                {

                    pcDesactivar.Add(p);

                }

            }

            Dynamicweb.Templatev2.Template template = new Dynamicweb.Templatev2.Template(dt.Rows[0]["template"].ToString());

            Dynamicweb.eCommerce.Frontend.Renderer r = new Dynamicweb.eCommerce.Frontend.Renderer();

            r.RenderProducts(pcDesactivar, template);  à the line that throws the exception

            sendEmail(template.Html, dt.Rows[0]["subject"].ToString(), dt.Rows[0]["mailServer"].ToString(), "campoNotificar", dt.Rows[0]["campoCC"].ToString(), dt.Rows[0]["remetente"].ToString());

 

 

The template I’m using

 

<style>

                .ShopImage{

                }

</style>

<table cellpadding=0 cellspacing=0 border=0>

                <tr>

                               <!--@DwShopProductList-->

                </tr>

</table>

<div align=right><!--@DwShopProductListButtonBack-->&nbsp;&nbsp;<!--@DwShopProductListButtonList-->&nbsp;&nbsp;<!--@DwShopProductListButtonForward--></div>

 

 

 

The exception

 

Dynamicweb.eCommerce.Variants.VariantGroupCollection' on assembly 'Dynamicweb, Version=18.9.1.1, Culture=neutral, PublicKeyToken=null' is not serializable

 


Replies

 
Reply
Hi Humberto

Could you paste a stack trace?

 - Lasse

 

You must be logged in to post in the forum