Bukimedia / PrestaSharp

CSharp .Net client library for the PrestaShop API via web service
GNU General Public License v3.0
154 stars 152 forks source link

Language Definition are not Updating or Empty #328

Open NearEarthObject opened 6 years ago

NearEarthObject commented 6 years ago

Hi everybody,

I experience a strange issue, I read carefully the different Issues to find some inspiration, and I simply past and glue some code fragment to experience It. So in my case as ManufacturerFactory belongs your favorite : ManufacturerFactory ManufacturerFactory = new ManufacturerFactory(BaseUrl, Account, Password); manufacturer Manufacturer = ManufacturerFactory.Get(6);

        Manufacturer.description.Add(new Entities.AuxEntities.language(1, "bla bla"));
        Manufacturer.name = "brand name";
        ManufacturerFactory.Update(Manufacturer);

The name update perfectly, but all fields relaying on language Fields like in this example description are not. I also experience to change in Prestashp Class definition fiels description addind : required = true, In this case, I face a crash : `<?xml version="1.0" encoding="utf-8"?>

6 brand name 2017-10-30 15:14:51 2018-06-22 12:36:07 1 ` followed by : `application/json, application/xml, text/json, text/x-json, text/javascript, text/xml, text/html` ` description is empty"]]> HttpStatusCode: BadRequest` I explore the different similar issie post to fix It without any success. So a piece of help from developers or users would be highly appreciated ! Regards Jeff
NearEarthObject commented 6 years ago

After a long exploration, I eventually fix the issue. So I don't know if It belongs to an update of Prestashop (I currently run 1.6.19 the last one in 1.6), but the correct sentence to update a language field like product->name is : `

Prod 1 ` The current Entities.AuxEntities.language return ` ` So there is probably a better solution, but I momentously solve the situation by removing ` [XmlAttribute]` in language.cs regarding `public string Value` like this : `// Value is reserved word from RestSharp for loading the CDATA content from the XML file.` ` [DataMember]` ` public string Value { get; set; }` And in RestSharpFactory.cs protected RestRequest RequestForUpdate(string Resource, long? Id, Entities.PrestaShopEntity PrestashopEntity) I add two lines : `request.Parameters[1].Value = request.Parameters[1].Value.ToString().Replace("", "");` `request.Parameters[1].Value = request.Parameters[1].Value.ToString().Replace("", "");` I think there is probably a better way to achieve this, I keep the issue open for any suggestion or code improvement most accurate. Jeff