Add Product - error Property Product->link_rewrite is empty
Hi when I try to add a product we have the error: Property Product->link_rewrite is empty
You can insert link_rewrite doing this:
product prod = new product(); string name = "Name of product" Bukimedia.PrestaSharp.Entities.AuxEntities.language auxLang = new Bukimedia.PrestaSharp.Entities.AuxEntities.language(); auxLang.Value = name.ToLower().Replace(" ", "-"); auxLang.id = 1; prod.link_rewrite.Add(auxLang);
Unfortunately, it does not work Below I attach the XML and the error
application/json, application/xml, text/json, text/x-json, text/javascript, text/xml, text/html
HttpStatusCode: BadRequest
You have probably forgotten to change the namespace in Bukimedia.PrestaSharpSerializer.cs
I moved the the location of Bukimedia.PrestaSharp.Entities.AuxEntities.language -> shop.api.prestashop.Entities.AuxEntities.language and the auto-apply-rename updated alle references except from the "Bukimedia.PrestaSharp.Entities.AuxEntities.language", since they were in a string.
Everything worked after that, and the "
Example from code: (- = before, and + = after)
private void Map(XElement root, object obj)
{
var name = prop.Name;
var rawValue = prop.GetValue(obj, null);
- //Hack to serialize Bukimedia.PrestaSharp.Entities.AuxEntities.language
- if (obj.GetType().FullName.Equals("**Bukimedia.PrestaSharp.Entities.AuxEntities.language**") && root.Name.LocalName.Equals("language") && name.Equals("id"))
+ //Hack to serialize shop.api.prestashop.Entities.AuxEntities.language
+ if (obj.GetType().FullName.Equals("**shop.api.prestashop.Entities.AuxEntities.language**") && root.Name.LocalName.Equals("language") && name.Equals("id"))
{
-
root.Add(new XAttribute(XName.Get("id"), rawValue));
continue;
}
- else if (obj.GetType().FullName.Equals("**Bukimedia.PrestaSharp.Entities.AuxEntities.language**") && root.Name.LocalName.Equals("language") && name.Equals("Value"))
+ else if (obj.GetType().FullName.Equals("**shop.api.prestashop.Entities.AuxEntities.language**") && root.Name.LocalName.Equals("language") && name.Equals("Value"))
{
XText xtext = new XText(rawValue == null ? "" : rawValue.ToString());
root.Add(xtext);
}