Hi thereI need some help from you guys.Im trying to make an XSLT Extension give me all products in the shop (2.6.1), but im getting an error."Cannot serialize member UCommerce.EntitiesV2.Product.Variants of type System.Collections.Generic.ICollection`1[[UCommerce.EntitiesV2.Product, UCommerce, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]] because it is an interface."public string GetAllProducts(){StringBuilder sb = new StringBuilder();List<Product> productList = Product.All().ToList<Product>();XmlWriter xmlWriter = XmlWriter.Create(sb);XmlSerializer serializer = new XmlSerializer(typeof(Product));serializer.Serialize(xmlWriter, productList);xmlWriter.Dispose();return sb.ToString();}
Im trying to make an XSLT Extension give me all products in the shop (2.6.1), but im getting an error.
"Cannot serialize member UCommerce.EntitiesV2.Product.Variants of type System.Collections.Generic.ICollection`1[[UCommerce.EntitiesV2.Product, UCommerce, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]] because it is an interface."
public string GetAllProducts() { StringBuilder sb = new StringBuilder(); List<Product> productList = Product.All().ToList<Product>(); XmlWriter xmlWriter = XmlWriter.Create(sb); XmlSerializer serializer = new XmlSerializer(typeof(Product)); serializer.Serialize(xmlWriter, productList); xmlWriter.Dispose(); return sb.ToString(); }
It's a limitation inherent in the .NET XmlSerializer. You can use the built-in XML renderers that ship out of the box with uCommerce.
The one for converting a product to XML is called ProductRenderer and lives in the UCommerce.Xslt namespace.
Why aren't out letting the LINQ API perform the search prior to performing the search? It would make the solution much, much faster as it would only have to deal with a minimum of information.
Get all products via XSLT-Extension
Hi thereI need some help from you guys.Im trying to make an XSLT Extension give me all products in the shop (2.6.1), but im getting an error."Cannot serialize member UCommerce.EntitiesV2.Product.Variants of type System.Collections.Generic.ICollection`1[[UCommerce.EntitiesV2.Product, UCommerce, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]] because it is an interface."public string GetAllProducts(){StringBuilder sb = new StringBuilder();List<Product> productList = Product.All().ToList<Product>();XmlWriter xmlWriter = XmlWriter.Create(sb);XmlSerializer serializer = new XmlSerializer(typeof(Product));serializer.Serialize(xmlWriter, productList);xmlWriter.Dispose();return sb.ToString();}
Hi there
I need some help from you guys.
Im trying to make an XSLT Extension give me all products in the shop (2.6.1), but im getting an error.
"Cannot serialize member UCommerce.EntitiesV2.Product.Variants of type System.Collections.Generic.ICollection`1[[UCommerce.EntitiesV2.Product, UCommerce, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]] because it is an interface."
public string GetAllProducts()
{
StringBuilder sb = new StringBuilder();
List<Product> productList = Product.All().ToList<Product>();
XmlWriter xmlWriter = XmlWriter.Create(sb);
XmlSerializer serializer = new XmlSerializer(typeof(Product));
serializer.Serialize(xmlWriter, productList);
xmlWriter.Dispose();
return sb.ToString();
}
It's a limitation inherent in the .NET XmlSerializer. You can use the built-in XML renderers that ship out of the box with uCommerce.
The one for converting a product to XML is called ProductRenderer and lives in the UCommerce.Xslt namespace.
Why aren't out letting the LINQ API perform the search prior to performing the search? It would make the solution much, much faster as it would only have to deal with a minimum of information.
is working on a reply...