Bukimedia / PrestaSharp

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

Create and update products #290

Closed flopez2904 closed 5 years ago

flopez2904 commented 7 years ago

HI, I need to develop an application that synchronizes the items of an erp software with a prestashop store.

I need some example of how to create a new article and how to update one that already exists.

SarayPerez commented 7 years ago

Hello,

I hope this example will suit you:

ProductFactory ArticuloFactory = new ProductFactory(BaseUrl, Account, Password);
Bukimedia.PrestaSharp.Entities.AuxEntities.language Lenguaje = new Bukimedia.PrestaSharp.Entities.AuxEntities.language();

Lenguaje.id = 1;
var MiArticulo = new product();

MiArticulo.reference = "123456";
MiArticulo.active = 1;
MiArticulo.minimal_quantity = 1;
MiArticulo.show_price = 1;
MiArticulo.available_for_order = 1;
MiArticulo.is_virtual = 0;
MiArticulo.visibility = "both";
MiArticulo.advanced_stock_management = 0;
MiArticulo.date_add = "2017-10-11 11:15:20";
MiArticulo.id_tax_rules_group = 1;
MiArticulo.id_category_default = 1;
MiArticulo.id_shop_default = 1;
MiArticulo.price = Convert.ToDecimal(10.99);
MiArticulo.name.Add(new Bukimedia.PrestaSharp.Entities.AuxEntities.language((long)1, "Name");
Lenguaje.Value = "Name";
MiArticulo.AddLinkRewrite(Lenguaje);

MiArticulo.associations.categories.Add(new Bukimedia.PrestaSharp.Entities.AuxEntities.category((long)1));

try { ArticuloFactory.Add(MiArticulo); }
catch (System.NullReferenceException e) { }
mowcixo commented 5 years ago

Closing as it is answered by @SarayPerez correctly.

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.