void LoadProduct()
{
int catalogValue = -1;
if (base.ContainerValue > 0)
{
catalogValue = base.ContainerValue;
}
else
{
if (!string.IsNullOrEmpty(CMSConfig.QueryString.CatalogID))
{
int.TryParse(Request.QueryString[CMSConfig.QueryString.CatalogID], out catalogValue);
}
}
if (base.XSLTemplateID > 0)
{
List<Product> products = ProductManager.GetProductsByCatalogID(catalogValue, CMSContext.PortalID, CMSContext.LanguageID);
string xslPath = CMSWebHelper.GetXSLTemplateFilePath(base.XSLTemplateID);
xslPath = XSLTemplateManager.GetXSLTemplatePath(xslPath, base.XSLTemplateID);
XmlDocument xmlDoc = new XmlDocument();
XmlElement root = xmlDoc.CreateElement("Products");
xmlDoc.AppendChild(root);
if (products != null && products.Count > 0)
foreach (Product product in products)
{
XmlElement productElement = xmlDoc.CreateElement("Product");
XmlAttribute attr = xmlDoc.CreateAttribute("ID");
attr.Value = product.ID.ToString();
productElement.Attributes.Append(attr);
attr = xmlDoc.CreateAttribute("Name");
attr.Value = product.Name.ToString();
productElement.Attributes.Append(attr);
List<ProductImage> productImages =
ProductImageManager.GetProductImagesByProductID(product.ID, CMSContext.LanguageID);
if (productImages != null && productImages.Count > 0)
for (int i = 0; i <= productImages.Count - 1; i++)
{
XmlElement productImageElement = xmlDoc.CreateElement("Image");
XmlAttribute imageAttr = xmlDoc.CreateAttribute("ID");
imageAttr.Value = productImages[i].ID.ToString();
productImageElement.Attributes.Append(imageAttr);
imageAttr = xmlDoc.CreateAttribute("ImageCaption");
imageAttr.Value = productImages[i].ImageCaption;
productImageElement.Attributes.Append(imageAttr);
imageAttr = xmlDoc.CreateAttribute("Image");
imageAttr.Value = productImages[i].Image;
productImageElement.Attributes.Append(imageAttr);
productElement.AppendChild(productImageElement);
}
root.AppendChild(productElement);
}
if (xmlDoc.ChildNodes.Count > 1)
{
XmlAttribute xmlAtt = xmlDoc.CreateAttribute("CurrentCatalog");
xmlAtt.Value = catalogValue.ToString();
xmlDoc.ChildNodes[1].Attributes.Append(xmlAtt);
}
XsltArgumentList arguments = new XsltArgumentList();
arguments.AddExtensionObject("CMS:UserControl", this);
xmlProduct.DocumentContent = xmlDoc.OuterXml;
xmlProduct.TransformSource = xslPath;
xmlProduct.TransformArgumentList = arguments;
xmlProduct.DataBind();
}
}
#endregion