示例#1
0
文件: mage.cs 项目: chisan0501/ic_ef
        //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);
        }
示例#2
0
        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+"";
        }
示例#3
0
        public override PushState Create(out string destinationId)
        {
            var pushState = PushState.Success;

            soap.SetOptions(Adapter.Options);
            var indexedModel     = GetIndexModel();
            var additionalFields = IndexedItem.Properties().Where(p => !HexaFields.Contains(p.Name) && !ProductFields.Contains(p.Name)).Select(p => p.Name);
            var websiteIds       = Regex.Split(Options.FirstOrDefault(o => o.Name == "website_ids").Value, "[,;|]", RegexOptions.Multiline | RegexOptions.IgnoreCase);
            var storeIds         = Regex.Split(Options.FirstOrDefault(o => o.Name == "store_ids").Value, "[,;|]", RegexOptions.Multiline | RegexOptions.IgnoreCase);
            var normalizedValues = GetNormalizedValuesByDependencies();

            try
            {
                var additionalAttrs = additionalFields.Select(f => new associativeEntity
                {
                    key   = f,
                    value = normalizedValues.ContainsKey(f) ? normalizedValues[f] : IndexedItem.Value <string>(f)
                });

                var attributes = new catalogProductAdditionalAttributesEntity {
                    single_data = additionalAttrs.ToArray()
                };
                var data = new catalogProductCreateEntity
                {
                    website_ids           = websiteIds,
                    additional_attributes = attributes,
                    status     = "2",
                    visibility = "4",
                    stock_data = new catalogInventoryStockItemUpdateEntity()
                    {
                        qty         = "0",
                        is_in_stock = 1,
                    }
                };

                soap.Begin();
                var client = soap.GetClient();
                destinationId = client
                                .catalogProductCreate(soap.GetSession(),
                                                      normalizedValues.ContainsKey("type") ? normalizedValues["type"] : IndexedItem.Value <string>("type"),
                                                      normalizedValues.ContainsKey("attribute_set_id") ? normalizedValues["attribute_set_id"] : IndexedItem.Value <string>("attribute_set_id"),
                                                      IndexedItem.Value <string>("sku"),
                                                      data,
                                                      "0").ToString();
                foreach (var storeId in storeIds)
                {
                    client.catalogProductMultiUpdateAsync(
                        soap.GetSession(),
                        new string[] { destinationId },
                        new catalogProductCreateEntity[]
                    {
                        new catalogProductCreateEntity
                        {
                            website_ids = websiteIds,
                            status      = "2" // Creating product always set status to false. itemModel.removed == DIndex.ConstYes ? "2" : "1"
                        }
                    },
                        storeId,
                        "id");
                }

                return(pushState);
            }
            finally
            {
                soap.End();
            }
        }