Hello.
If some of you are using NopCommerce with E-Conomic, it might become useful to parse some data to E-Conomic.
Here are some examples for you.
// Upload all products
protected void btnUploadProductVariants_Click(object sender, EventArgs e)
{
/* Creates all ProductVariants*/
// Lag ny Econonic session
EconomicSession session = new EconomicSession();
session.Connect(id,user,pass);
foreach (Product p in ProductService.GetAllProducts(true))
{
foreach (ProductVariant pv in p.ProductVariants)
{
IProduct _product = session.Product.FindByNumber(pv.ProductVariantId.ToString());
if (_product == null)
{
// Create
_product = session.Product.Create(pv.ProductVariantId.ToString(), session.ProductGroup.FindByNumber(1), pv.Product.Name + " / " + pv.Product.ShortDescription); // we add all products to group nr 1
_product.SalesPrice = pv.Price / (decimal)1.25; // divide by 1.25 if you want to deduct 25% vat
_product.IsAccessible = true;
_product.BarCode = pv.SKU;
_product.CostPrice = pv.ProductCost;
lblOut.Text += "<br/>Lagt inn produktnr : " + _product.Number.ToString() + " (" + _product.Name + ")"; // I've got a label that tells me twhich products was added and not
}
else
{
// Update
// Create
_product.Name = ""+pv.Product.Name + " / " + pv.Product.ShortDescription+"";
_product.SalesPrice = pv.Price / (decimal)1.25;
_product.IsAccessible = true;
_product.BarCode = pv.SKU;
_product.CostPrice = pv.ProductCost;
lblOut.Text += "<br/>Oppdatert produktnr : " + _product.Number.ToString() + " (" + _product.Name + ")";
}
}
}
// Avslutt session
session.Disconnect();
}
If some of you are using NopCommerce with E-Conomic, it might become useful to parse some data to E-Conomic.
Here are some examples for you.
// Upload all products
protected void btnUploadProductVariants_Click(object sender, EventArgs e)
{
/* Creates all ProductVariants*/
// Lag ny Econonic session
EconomicSession session = new EconomicSession();
session.Connect(id,user,pass);
foreach (Product p in ProductService.GetAllProducts(true))
{
foreach (ProductVariant pv in p.ProductVariants)
{
IProduct _product = session.Product.FindByNumber(pv.ProductVariantId.ToString());
if (_product == null)
{
// Create
_product = session.Product.Create(pv.ProductVariantId.ToString(), session.ProductGroup.FindByNumber(1), pv.Product.Name + " / " + pv.Product.ShortDescription); // we add all products to group nr 1
_product.SalesPrice = pv.Price / (decimal)1.25; // divide by 1.25 if you want to deduct 25% vat
_product.IsAccessible = true;
_product.BarCode = pv.SKU;
_product.CostPrice = pv.ProductCost;
lblOut.Text += "<br/>Lagt inn produktnr : " + _product.Number.ToString() + " (" + _product.Name + ")"; // I've got a label that tells me twhich products was added and not
}
else
{
// Update
// Create
_product.Name = ""+pv.Product.Name + " / " + pv.Product.ShortDescription+"";
_product.SalesPrice = pv.Price / (decimal)1.25;
_product.IsAccessible = true;
_product.BarCode = pv.SKU;
_product.CostPrice = pv.ProductCost;
lblOut.Text += "<br/>Oppdatert produktnr : " + _product.Number.ToString() + " (" + _product.Name + ")";
}
}
}
// Avslutt session
session.Disconnect();
}
Statistics: Posted by olejohan — Tue Feb 19, 2013 10:55 pm — Replies 0 — Views 2