I've Integrated an Excel Bulk File Upload w/ Pictures (images)

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
13 years ago
Glenn...

I've recreated Glenn's issue and there is indeed an issue.

Maybe someone can help with why this isn't working on production servers?

I'll keep at it until someone else beats me to it.

Until then, if you just want to get your site up (which is my motivation) then run the code on your local iis server and then update your website from your local files.

As far as database, you can connect to a remote database from your local iis or connect to local database and then update your remote.  I would recommend the later as this gives backups.
13 years ago
ajhvdb...

It seems like your trying to grasp the concept of Product and Varient.  First, understand that there is a difference in the way it is structured wether you manually input the information or if you do a bulk insert.  Since we are trying to do a bulk insert lets look only at that...

- Each item in your Excel spreadsheet is inserted as a Product.  The item has a productID and a product_variantID.
- Each Product Variant is mapped to the productID.

So if you wanted to change an item from Product to Product Varient... you have to change the TemplateID to 4 and change the nop_ProductVariant table's productID to the corresponding Product.

Example:
nop_ProductVariant Table

| ProductVariantID | ProductID | Name...
| 1                        |1              
| 2                        |1
| 3                        |3

Product 1 has two Variants:  Itself, and another.  Product 3 has only itself.  Product 1 should have a templateID of 4 to show a grid of its variants and Product 3 should have a templateID of 5 as it is a single product.

Q. Which picture is Default?  
A. I have assigned the default picture with only the sku (ex: ADO77553.jpg) with no extension of _2 or _3 (ex: ADO77553_2.jpg, or ADO7753_3.jpg).  This is going to have to be a semi-manual process as no logic that can figure out which picture you want for each item, that is why it is best to use the sku as a naming convention.
13 years ago
Ok, I get it so far :)

But the TemplateID, couldn't find much with the search. Any documentation about that?
13 years ago
OK... it seems like the bin file isn't building properly (ie. the BusinessLogic DLL is not updating properly).  The reason I say this is because NONE of the updates are working; including the Name insert which has nothing to do with the pictures.
13 years ago
Totally lost on the above answer ? sorry

ajhvdb wrote:
Ok, I get it so far :)
But the TemplateID, couldn't find much with the search. Any documentation about that?


Could you reply to this?
13 years ago
hrdfsique wrote:
Glenn...

I've recreated Glenn's issue and there is indeed an issue.

Maybe someone can help with why this isn't working on production servers?

I'll keep at it until someone else beats me to it.

Until then, if you just want to get your site up (which is my motivation) then run the code on your local iis server and then update your website from your local files.

As far as database, you can connect to a remote database from your local iis or connect to local database and then update your remote.  I would recommend the later as this gives backups.



hrdfsique -

I don't actually have my store files saved locally, just a test site that I use for testing this stuff. I installed my live site direct to my website (probably a silly thing to do). I also don't have my database saved locally and at present don't know how to get a copy of it to my computer. I do of course take backups of both my site and database, but my database server does not allow me to save the database to my PC.

I have been playing around with this and this is the outcome.

1. I downloaded all my web server files.
2. I modified my connection string to point to my live database, but created a backup first!
3. I then replaced the three "Nop.BusinessLogic" files in my local bin folder with the ones from yours.
4. I also modified the xls to point to the correct path on my PC.
5. Then I launched the site from VWD (I haven't been using iis either)

Now when I build my site in VWD and it launches, when I upload the xls it creates the products and adds the thumb nail image. It also updates this on my live site so when I go to my live store the products are there too, with the images :o)

I don't really know how it is doing this as I have not uploaded any files to the web, i.e. "Nop.BusinessLogic"/bin files. I gather it is doing this through the connectionstrings file. However this has made me very happy! Ideally I now need to get a full copy of my live website files and database so I can do all of these changes locally and then just upload both to my server when complete.

I Hope this helps. Thanks a lot for your help and I will keep an eye on the post for updates, as I am sure I will want to be able to add multiple pictures for single products soon.

Thanks again

Glenn.
13 years ago
ajhvdb...


here is updated code for the ImportManager to locate up to 11 pictures for each product and insert.  You notice that I hard coded in the variables.  It works like a charm.

Now if some could could code in the user input for the file location and the number of pictures to find while I try to find a solution for what's happining with Glenn and the hosted environment.  We're Golden!

here is the code:



                        //Add the picture insert here so we can enter the default image (picture.PictureId) into Variant
                        string directory = "c:\\product_pics\\";
                        int i = 0;
                        int picID = 0; //set a variable when inserting picture and assign to productVariant
                        do
                        {
                            if (product != null)
                            {
                                string image = null;
                                if (i == 0)
                                {
                                    image = directory + SKU + ".jpg";//create default image - which has no underscore and number.
                                }
                                else
                                {
                                    image = directory + SKU + "_" + i + ".jpg";
                                }

                                if (image != null)
                                {
                                    if (File.Exists(image))
                                    {
                                        Picture picture = PictureManager.InsertPicture(PictureManager.GetImageBytes(image), PictureManager.GetContentType(image), true);
                                        if (picture != null)
                                        {
                                            ProductPicture productPicture = ProductManager.InsertProductPicture(product.ProductId, picture.PictureId, 1);
                                            picID = picture.PictureId;
                                        }
                                    }
                                }


                                i++;
                            }
                        }
                        while (i <= 4);  //Determines the amount of pictures to search for.
13 years ago
By the way...

Using the above code negates the need to change the excel file.  The only requirement would still be that the pictures be named with the same SKU:  

   ABC123.jpg
   ABC123_1.jpg
   ABC123_2.jpg
   ABC123_3.jpg
   ABC123_4.jpg
   ABC123_5.jpg
   etc.

I believe we should still try to do the bulk upload from the client side... So the directory location variable should coincide.  This is also what I am working on for an actual hosting environment.
13 years ago
Glenn,

Thanks for your post on my thread regarding importing bulk items - haven't tried your code yet but will do so based on the answers to my Q's below (if you have a minute to reply).

Regarding products and variants and your code - all my items are one-offs (I sell "pre-loved" DVD's, books, CD's and LP's) so I *almost never* have more than one of anything.... do I still need a product and a product variant or are they  one and the same anyway (i.e: the product variant is the exact same item as the product in the tables)?

I'm very new to nopCommerce so sorry if I'm not getting the gist but essentially I want to import from a file based on the existing nop import template along with extra columns for image name (I only need one), category ID (I will add categories into nop as I only have a few) and item template ID (which I think would always be 5 for me as I have no variants) - is this essentially what your importer does or would I have to further edit your code to enable this?

Thanks, I'm sure we all appreciate the hard work you've put in to get this running!

Mike
13 years ago
Scusate se mi intrometto ..
Posso usare NELLA also version 1.5?
( https://www.nopcommerce.com/boards/t/6262/ive-integrated-an-excel-bulk-file-upload-w-pictures-images-into-v18.aspx
)
Grazie
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.