PrestaSharp
PrestaSharp copied to clipboard
Deserialization fails on product with accessories
Deserialization fails on product with accessories. The error is "Sequence contains more than one element". I think is confuse the root "product" element with the elements "product" in accessories. I try to fix this by adding xml attributes with no success.
example
[XmlType(Namespace = "Bukimedia/PrestaSharp/Entities/AuxEntities")]
public class AssociationsProduct : PrestaShopEntity
{
[XmlArray("categories")]
[XmlArrayItem("category")]
public List<category> categories { get; set; }
[XmlArray("images")]
[XmlArrayItem("image")]
public List<image> images { get; set; }
[XmlArray("combinations")]
[XmlArrayItem("combination")]
public List<combinations> combinations { get; set; }
[XmlArray("product_option_values")]
[XmlArrayItem("product_option_value")]
public List<product_option_value> product_option_values { get; set; }
[XmlArray("product_features")]
[XmlArrayItem("product_feature")]
public List<product_feature> product_features { get; set; }
[XmlArray("tags")]
[XmlArrayItem("tag")]
public List<tag> tags { get; set; }
[XmlArray("stock_availables")]
[XmlArrayItem("stock_available")]
public List<stock_available> stock_availables { get; set; }
[XmlArray("product_bundle")]
[XmlArrayItem("product")]
public List<products> product_bundle { get; set; }
[XmlArray("accessories")]
[XmlArrayItem("product")]
public List<product> accessories { get; set; }
public AssociationsProduct()
{
this.categories = new List<category>();
this.images = new List<image>();
this.combinations = new List<combinations>();
this.product_option_values = new List<product_option_value>();
this.product_features = new List<product_feature>();
this.tags = new List<tag>();
this.stock_availables = new List<stock_available>();
this.product_bundle = new List<products>();
this.accessories = new List<product>();
}
}
I restore the old PrestaSharpDeserializer, PrestaSharpSerializer and make the changes for the new interfaces IDeserializer and ISerializer of restsharp and now is deserialize the product with accessories as normal.