Programatically add Products

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
11 years ago
If you just are going to do this export/import only once, you should look into nopCommerce built in feature for importing from an excel doc. If you need more advanced import; nopAdmin has a very good tool for importing products, including variants, attributes, specifications etc.
7 years ago
I'm trying to develop a plugin where I "import" products from an external store, these products are not insterted in nopCommerce´s database due to the big quantity of products that I need to import.

I can show external products in homepage but i'm having so many problems trying to add an external product to Cart and continue with payment process.

Is nopCommerce the right tool for what I need to do?
Can nopCommerce work as I describe above?

Helpme please!


Thanks!,
Andrés
4 years ago
mrhammad wrote:
Many thanks i really appreciate your help , ok now another thing i have MS SQL database which has a table of categories and Products, i want to fetch it from that DB and insert into nopCommerce DB, how can i achieve this?

My Controller look like this now.

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Mvc;
using Nop.Admin.Models.Catalog;
using Nop.Core.Domain.Catalog;
using Nop.Core.Infrastructure;
using Nop.Plugin.Misc.ProductImport.Models;
using Nop.Services.Catalog;

namespace Nop.Plugin.Misc.Product.Controllers
{
    class ProductImportController : Controller
    {
        //
        // GET: /Default1/
        public void CreateProduct()
        {
            //product service
            var _productService = new NopEngine().Resolve<IProductService>();
            
            // category service
            var _categoryService = new NopEngine().Resolve<ICategoryService>();

            //declare product instance
            Core.Domain.Catalog.Product prod = new Core.Domain.Catalog.Product()
            {
                Name = "DELL 4530",
                UpdatedOnUtc = DateTime.UtcNow,
                CreatedOnUtc = DateTime.UtcNow,
            };
            
            //add product via product service
            _productService.InsertProduct(prod);

            //create category instance
            Category _category = new Category()
            {
                Name = "Laptops"
            };            

            //relate category & product
            var productCategory = new ProductCategory
            {
                ProductId = prod.Id,
                Product = prod,
                Category = _category,
                CategoryId = _category.Id
            };

            //add product category
            _categoryService.InsertProductCategory(productCategory);
        }
    }
}


Good but dead link to product detail page

how to do this problem???????????

This problem passes after I edit this product manually after adding it.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.