Bukimedia / PrestaSharp

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

Inserting products fails with Prestashop 1.7.3 #318

Open javiercampos opened 6 years ago

javiercampos commented 6 years ago

There are two new fields, one of them can't be null, so inserting fails. The fields are low_stock_alert (a boolean/int) and low_stock_threshold (an int).

I've put them in product and everything worked again, but I'm not sure if that will break compatibility with previous versions (maybe if the data is sent in the REST request it will fail, I can't test it right now).

KouzelisChris commented 6 years ago

your solution doesn't break compatibility with versions 1.7 and higher

SarayPerez commented 5 years ago

Hello! ,

Can anyone tell me how I can put that new fields in PrestaSharp in my Visual Studio 2013 project? Thanks in advance! Saray Pérez

KouzelisChris commented 5 years ago

Hello! ,

Can anyone tell me how I can put that new fields in PrestaSharp in my Visual Studio 2013 project? Thanks in advance! Saray Pérez

You have to edit Bukimedia/PrestaSharp and add the 2 fields. After that Bukimedia.PrestaSharp.Entities.product will have the 2 new fields. I have attached my Bukimedia.PrestaSharp which have the 2 fields if you cant edit it on your own

Bukimedia.PrestaSharp.zip

mowcixo commented 5 years ago

Hello, we just released the official NuGet release that fixes the related problem. Yo can find it searching by PrestaSharp in nuget repositories, or the release https://github.com/Bukimedia/PrestaSharp/releases/tag/1.0.0

Sorry for the delay and thanks for waiting.

biovolt commented 5 years ago

Hi This breaks when decoding a response coming back from prestashop where low_stock_threshold is "" and it tries to convert it to an int. It throws a System.FormatException: 'Input string was not in a correct format.' on PrestaSharpDeserializer.cs ln 130

Dictionary<string, string> dtn = new Dictionary<string, string>(); dtn.Add("supplier_reference", sku); Bukimedia.PrestaSharp.Entities.product product = this.productFactory.GetByFilter(dtn, null, null).FirstOrDefault()

Prestashop 1.7.4.4 & 1.7.5

albertg5 commented 5 years ago

This issue haven't fixed yet, because I use the last version of Prestasharp, I try to add product to Prestahop 1.7.4.3 and it still appears.

mowcixo commented 5 years ago

This issue haven't fixed yet, because I use the last version of Prestasharp, I try to add product to Prestahop 1.7.4.3 and is still appearing it.

What version number are you using?

albertg5 commented 5 years ago

1.0.5. The last version available in Nuget Package Manager

mowcixo commented 5 years ago

1.0.5. The last version available in Nuget Package Manager

Ok, thanks for the feedback, are you using an example similar as mentioned in @biovolt comment?:

Hi This breaks when decoding a response coming back from prestashop where low_stock_threshold is "" and it tries to convert it to an int. It throws a System.FormatException: 'Input string was not in a correct format.' on PrestaSharpDeserializer.cs ln 130

Dictionary<string, string> dtn = new Dictionary<string, string>(); dtn.Add("supplier_reference", sku); Bukimedia.PrestaSharp.Entities.product product = this.productFactory.GetByFilter(dtn, null, null).FirstOrDefault()

Prestashop 1.7.4.4 & 1.7.5

If not, you'll help with your own code snippet :)

albertg5 commented 5 years ago

I'm trying to set low_stock_alert and low_stock_threshold and the error still appears. I have just tried with Prestashop 1.7.2.4 and it works properly

albertg5 commented 5 years ago

ProductFactory productFactory = new ProductFactory(BaseUrl, Account, Password); product p = new product();

//Here we assign several information inside of some properties

productFactory.Add(p);

albertg5 commented 5 years ago

Moises (mowcixo), I'm watching that other users have the same issue #365 #366 #369

mowcixo commented 5 years ago

Yes, I was digging into it yesterday, and it seems that in newer versions of PrestaShop, they consider 0 as "" on some webservice responses, I'll try to find a global solution for that. Thanks for your research on older issues.

albertg5 commented 5 years ago

Thank you to you for your efforts, as soon as you find a solution please let us know.

albertg5 commented 5 years ago

Mowcixo,

Have you some news about that?

Best regards