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

How can I add Specific_price to new product ? #309

Closed polaije closed 5 years ago

polaije commented 6 years ago

Hi, I have a new product and I add this list of specific prices: List<Bukimedia.PrestaSharp.Entities.specific_price> SpecificPrices = new List<Bukimedia.PrestaSharp.Entities.specific_price>(); Bukimedia.PrestaSharp.Entities.specific_price Spe = new Bukimedia.PrestaSharp.Entities.specific_price(); Spe.price = Convert.ToDecimal(textBoxDiscount.Text); Spe.reduction_type = "percentage"; SpecificPrices.Add(Spe); But how can I associate the specific price to the new product item ?

newProduct.associations has no specific price function.

Thanks helping me. Jean-Marie

mowcixo commented 5 years ago

Hello @polaije, I guess you already find out how to do that, but just in case, there is a SpecificPriceFactory for creating specific prices, that's why product has no associations with them.

You need to set the id_product property on each specific_price instance, and then, use the Add method from specific price factory for creating them.

Let me know if that solve you question. Also, there is a slack group created for solving questions like that, because the issue section of this repository is just for communicating bugs. Find out how to join to the slack group in the repository's home page.

lock[bot] commented 4 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.