PrestaSharp icon indicating copy to clipboard operation
PrestaSharp copied to clipboard

Inserting products fails with Prestashop 1.7.3

Open javiercampos opened this issue 6 years ago • 15 comments

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).

javiercampos avatar Mar 23 '18 12:03 javiercampos

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

KouzelisChris avatar May 21 '18 16:05 KouzelisChris

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

SarayPerez avatar Oct 09 '18 08:10 SarayPerez

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

KouzelisChris avatar Oct 09 '18 08:10 KouzelisChris

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.

mowcixo avatar Dec 20 '18 11:12 mowcixo

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

biovolt avatar Jan 08 '19 08:01 biovolt

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.

albertg5 avatar Aug 13 '19 11:08 albertg5

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?

mowcixo avatar Aug 13 '19 11:08 mowcixo

1.0.5. The last version available in Nuget Package Manager

albertg5 avatar Aug 13 '19 11:08 albertg5

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 :)

mowcixo avatar Aug 13 '19 11:08 mowcixo

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 avatar Aug 13 '19 11:08 albertg5

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

//Here we assign several information inside of some properties

productFactory.Add(p);

albertg5 avatar Aug 13 '19 11:08 albertg5

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

albertg5 avatar Aug 14 '19 09:08 albertg5

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.

mowcixo avatar Aug 14 '19 09:08 mowcixo

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

albertg5 avatar Aug 14 '19 09:08 albertg5

Mowcixo,

Have you some news about that?

Best regards

albertg5 avatar Aug 19 '19 09:08 albertg5