API Forum

This forum is in read-only mode.
Please refer to our API support in case you have any questions.
We can be reached at api@e-conomic.com
e-conomic API developer forum

NopCommerce to Economic : ProductVariants

0
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();


        }
created Feb 19, 2013 by olejohan
0% Accept Rate
Q 4 A 1 C 0

Visma e-conomic A/S
...