Dynamicweb.eCommerce.Products Namespace > Product Class : UpdateUnitCount Method |
class MyPage : System.Web.UI.Page { private Product product; public void StockForUnits(Product prod) { if (Request["saveUnit"] == "1") { AddProdUnit(prod); Dynamicweb.eCommerce.Variants.VariantOptionCollection units = Dynamicweb.eCommerce.Variants.VariantOption.getVariantOptions(prod, 1); Product.UpdateUnitCount(prod, units.Count); } } private void AddProdUnit(Product prd) { string reqName = null; string reqValue = null; if (Base.ChkNumber(prd.Type) == 0) { Dynamicweb.eCommerce.Stocks.StockUnit su = new Dynamicweb.eCommerce.Stocks.StockUnit(); su.Delete(prd.ID); foreach (string item in Request.Form) { reqName = item.ToString(); reqValue = Request[item]; if (reqName.IndexOf("PRODUNIT_ID") == 0) { if (!string.IsNullOrEmpty(reqValue)) { su.ProductID = prd.ID; su.VariantID = ""; su.UnitID = reqValue; su.Save(product.ID, "", reqValue); } } } } } }
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2