//use for retail picklist public int retail_quick_import(Models.retail_quick_import retail) { MagentoService mservice = new MagentoService(); String mlogin = mservice.login("admin", "Interconnection123!"); catalogProductCreateEntity create = new catalogProductCreateEntity(); catalogCategoryEntity add_cat = new catalogCategoryEntity(); catalogInventoryStockItemUpdateEntity stock_data = new catalogInventoryStockItemUpdateEntity(); stock_data.qty = "1"; stock_data.manage_stock = 1; stock_data.use_config_manage_stock = 0; stock_data.is_in_stock = 1; create.description = retail.desc; create.name = retail.name; create.price = retail.price; create.short_description = retail.short_desc; create.status = retail.status; create.visibility = retail.visible; create.weight = retail.weight; create.website_ids = retail.webistes; create.tax_class_id = retail.tax_id; create.stock_data = stock_data; associativeEntity[] attributes = new associativeEntity[3]; attributes[0] = new associativeEntity(); attributes[0].key = "vendor_id"; attributes[0].value = "11"; attributes[1] = new associativeEntity(); attributes[1].key = "approval"; attributes[1].value = "2"; attributes[2] = new associativeEntity(); attributes[2].key = "vendor_sku"; attributes[2].value = retail.sku + "_vendor"; catalogProductAdditionalAttributesEntity additionalAttributes = new catalogProductAdditionalAttributesEntity(); additionalAttributes.single_data = attributes; create.additional_attributes = additionalAttributes; int p_id = mservice.catalogProductCreate( mlogin, retail.type, retail.attr, retail.sku, create, "5"); mservice.catalogCategoryAssignProduct(mlogin, 2, retail.sku, "0", "SKU"); return(p_id); }
//this is currently connect to the dev site's SOAP Api //*** remeber to change it back to connect all SOAP API after live*** public void quick_update(string qty, string sku, string path) { MagentoService mservice = new MagentoService(); String mlogin = mservice.login("admin", "Interconnection123!"); catalogInventoryStockItemUpdateEntity qty_update = new catalogInventoryStockItemUpdateEntity(); qty_update.manage_stockSpecified = true; qty_update.is_in_stockSpecified = true; qty_update.use_config_manage_stockSpecified = true; qty_update.manage_stock = 1; qty_update.qty = qty; if (qty == "0") { qty_update.is_in_stock = 0; } else { qty_update.is_in_stock = 1; } qty_update.use_config_manage_stock = 1; mservice.catalogInventoryStockItemUpdate( mlogin, sku, qty_update); //catalogProductAttributeMediaCreateEntity photo = new catalogProductAttributeMediaCreateEntity(); //string image64 = image_to_64(path); //var imageEntity = new catalogProductImageFileEntity(); //imageEntity.content = image64; //imageEntity.name = "photo1"; //imageEntity.mime = "image/jpeg"; //photo.file = imageEntity; //photo.label = "label"; //photo.position = "0"; //photo.exclude = "0"; //photo.types = new[] { "image", "small_image", "thumbnail" }; //mservice.catalogProductAttributeMediaCreate(mlogin, retail.p_id, photo, "", "ID"); }
public int update_qty(string sku, string qty, string pid) { MagentoService mservice = new MagentoService(); String mlogin = mservice.login("admin", "Interconnection123!"); var item_to_update = new catalogInventoryStockItemUpdateEntity(); item_to_update.qty = qty; var result = mservice.catalogInventoryStockItemUpdate(mlogin, sku, item_to_update); try { HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create("http://connectall.org/update.php?product_id=" + pid + "&qty=" + qty); myHttpWebRequest.ContentType = "application/x-www-form-urlencoded"; myHttpWebRequest.UserAgent = ".NET Framework Test Client"; WebResponse wr = myHttpWebRequest.GetResponse(); } catch (WebException wex) { var pageContent = new StreamReader(wex.Response.GetResponseStream()) .ReadToEnd(); } return(result); }
static void MainPr(string[] args) { try { Navision_ItemCategory_Service.ItemCategories nv_Item_Cat = new Navision_ItemCategory_Service.ItemCategories(); Navision_ItemList_Service.ItemList_PortClient client = new Navision_ItemList_Service.ItemList_PortClient(); Navision_ItemList_Service.ItemList nv_ItemList = new Navision_ItemList_Service.ItemList(); Navision_ItemList_Service.ItemList[] nv_ItemLists; client.ClientCredentials.Windows.ClientCredential.UserName = "******"; client.ClientCredentials.Windows.ClientCredential.Password = "******"; client.ClientCredentials.Windows.ClientCredential.Domain = "122.166.222.116"; Navision_ItemList_Service.ItemList_Filter f = new Navision_ItemList_Service.ItemList_Filter(); nv_ItemLists = client.ReadMultiple(new Navision_ItemList_Service.ItemList_Filter[] { f }, null, 10000); MagentoConnectService.PortTypeClient mage_client = new MagentoConnectService.PortTypeClient(); string token_id = mage_client.login("webserviceuser", "apikey"); DBConnect db = new DBConnect(); Hashtable hs = db.fetch_CategoryMapping(); Hashtable hsp = db.fetch_ProductMapping(); for (int i = 0; i < nv_ItemLists.Length; i++) { MagentoConnectService.catalogProductCreateEntity mage_Product = new MagentoConnectService.catalogProductCreateEntity(); try { mage_Product.description = nv_ItemLists[i].Description; mage_Product.name = nv_ItemLists[i].Description; mage_Product.weight = "1"; mage_Product.price = nv_ItemLists[i].Last_Direct_Cost.ToString(); mage_Product.short_description = nv_ItemLists[i].Search_Description; string mage_cat_id = null; if (nv_ItemLists[i].Item_Category_Code != null) { mage_cat_id = (string)hs[nv_ItemLists[i].Item_Category_Code]; } string[] array = { mage_cat_id }; mage_Product.category_ids = array; mage_Product.status = "1"; mage_Product.visibility = "4"; String productType = "simple"; var stock = new catalogInventoryStockItemUpdateEntity { is_in_stockSpecified = true, is_in_stock = 1, qty = nv_ItemLists[i].Inventory.ToString() }; mage_Product.stock_data = stock; int productid = 0; try { if (db.fetch_Product(nv_ItemLists[i].No)) { mage_client.catalogProductUpdate(token_id, (string)hsp[nv_ItemLists[i].No], mage_Product, "default", productType); } else { productid = mage_client.catalogProductCreate(token_id, productType, "4", nv_ItemLists[i].No, mage_Product, "default"); db.InsertProductMapping(nv_ItemLists[i].No, productid.ToString(), nv_ItemLists[i].No); db.InsertLog("Product", nv_ItemLists[i].No, "Navision Product Code", "SUCCESS"); } } catch (Exception ex) { db.InsertLog("Product", nv_ItemLists[i].No, ex.ToString(), "FAILED"); } } catch (Exception ex) { db.InsertLog("Product", nv_ItemLists[i].No, ex.ToString(), "FAILED"); } } } catch (Exception ex) { MNC_Product_Sync.ErrorLog errLog = new MNC_Product_Sync.ErrorLog(); errLog.LogError("C:\\MNC_Logs", "Product " + ex.Message); } }
protected void export_Click(object sender, EventArgs e) { MagentoService mservice = new MagentoService(); String mlogin = mservice.login("admin", "Interconnection123"); string[] arr1 = new string[] { "1218" }; string product = "1"; catalogInventoryStockItemUpdateEntity update_item = new catalogInventoryStockItemUpdateEntity(); update_item.qty = "1"; update_item.is_in_stock = 1; var update = mservice.catalogInventoryStockItemUpdate(mlogin, product, update_item); var item = mservice.catalogInventoryStockItemList(mlogin, arr1); //working up_sell function //catalogProductLinkEntity assign = new catalogProductLinkEntity(); //assign.position = "1"; //mservice.catalogProductLinkUpdate(mlogin, "related", "1030", "1029", assign, "product_id"); catalogProductCreateEntity create = new catalogProductCreateEntity(); var inv = new catalogProductTierPriceEntity(); create.name = name.Text; create.price = price_control.Text; create.description = des.Text; create.short_description = short_des.Text; create.tax_class_id = "2"; create.meta_title = meta_info.Text; create.visibility = "4"; create.weight = "0"; create.status = "2"; create.meta_description = meta_description.Text; inv.qty = 0; associativeEntity[] attributes = new associativeEntity[18]; attributes[0] = new associativeEntity(); attributes[0].key = "asset_tag"; attributes[0].value = asset_tag.Text; attributes[1] = new associativeEntity(); attributes[1].key = "sku_family"; attributes[1].value = sku_family.Text; attributes[2] = new associativeEntity(); attributes[2].key = "cpu"; attributes[2].value = cpu.Text; attributes[3] = new associativeEntity(); attributes[3].key = "software_description"; attributes[3].value = soft_des.Text; attributes[4] = new associativeEntity(); attributes[4].key = "ram"; attributes[4].value = ram.Text + " RAM"; attributes[5] = new associativeEntity(); attributes[5].key = "hdd"; attributes[5].value = hdd.Text + " HDD"; attributes[6] = new associativeEntity(); attributes[6].key = "os"; attributes[6].value = software.Text; attributes[7] = new associativeEntity(); attributes[7].key = "creation_date"; attributes[7].value = create_date.Text; attributes[8] = new associativeEntity(); attributes[8].key = "wireless"; attributes[8].value = wireless.SelectedItem.ToString(); attributes[9] = new associativeEntity(); attributes[9].key = "incl"; attributes[9].value = includes.Text; attributes[10] = new associativeEntity(); attributes[10].key = "brand"; attributes[10].value = brand.Text; attributes[11] = new associativeEntity(); attributes[11].key = "grade"; attributes[11].value = grade.SelectedItem.Value; attributes[12] = new associativeEntity(); attributes[12].key = "wcoa"; attributes[12].value = wcoa.Text; attributes[13] = new associativeEntity(); attributes[13].key = "ocoa"; attributes[13].value = ocoa.Text; attributes[14] = new associativeEntity(); attributes[14].key = "video"; attributes[14].value = video_card.Text; attributes[15] = new associativeEntity(); attributes[15].key = "display"; attributes[15].value = screen.Text; attributes[16] = new associativeEntity(); attributes[16].key = "computer"; attributes[16].value = is_computer.SelectedValue; attributes[17] = new associativeEntity(); attributes[17].key = "optical"; attributes[17].value = optical.Text; catalogProductAdditionalAttributesEntity additionalAttributes = new catalogProductAdditionalAttributesEntity(); additionalAttributes.single_data = attributes; create.additional_attributes = additionalAttributes; mservice.catalogProductCreate( mlogin, "simple", "4", sku.Text, create, "1"); mservice.Dispose(); //update inventory catalogInventoryStockItemUpdateEntity qty_update = new catalogInventoryStockItemUpdateEntity(); qty_update.qty = qty.Text; qty_update.is_in_stock = int.Parse(stock_Availability.SelectedValue); mservice.catalogInventoryStockItemUpdate( mlogin, sku.Text, qty_update); get_magento_list(sku.Text); ClearTextBoxes(Page); //string content = "admin,,Default,simple,,,0,"+status.SelectedItem.ToString()+ ",No,\"Catalog, Search\",Yes,"+tax_class.SelectedItem.ToString()+ ",No,No,Yes,No,No,\"" + name.Text+ "\",,," + software.Text+ ","+cpu.Text+","+hdd.Text+",,"+ram.Text+ ",Use config,Use config,\"" + meta_info.Text+ "\",\"" + meta_description.Text+ "\",,,,,No layout updates,Block after Info Column,No,,,,,,"+brand.Text+ ",\"" + includes.Text+ "\"," + grade.SelectedItem.ToString()+",,,,,,,,,,,,,,,,,,"+wireless.SelectedItem.ToString()+ ",,,,,,,,,,,,,," + des.Text + ",\"" + short_des.Text+ "\",,,\"" + soft_des.Text+ "\",,,,,,,,,,,1,0,1,0,0,1,1,1,0,1,0,,,1,0,1,0,1,0,1,0,0,0,1,\"" + name.Text+ "\",0,simple,,,,,,,,,,," + asset_tag.Text+","+sku_family.Text+","+create_date.Text+""; }