I'm new to nopCommerce and struggling somewhat to find a way to rapidly add product images. At first I thought I could simply drop them into the wwroot/images folder, add records to Picture adding the file name and path in VirtualPath, then the corresponding map in Product_Picture_Mapping, but that failed. I then manually added some images to see what it did and realised the image name corresponds to the ID in Picture, so, rather than rename all images I figured I'd use the existing tools to download the existing products, add the image file path and import again. However, that also failed stating "Image cannot be loaded. Available decoders:- PNG : PngDecoder- BMP : BmpDecoder- GIF : GifDecoder- JPEG : JpegDecoder", despite all being jpg's. This seemed odd but just to make sure, I optimised every image saving as _min.jpg to a new folder. I then modified the filepath on the Excel upload file and tried again but got the same error. Can anyone suggest what might be wrong? On a separate note I can see that image management appears to have been an issue in the past and that 3rd party add ons have been created to assist. Can anyone recommend one that is genuinely beneficial?
Others have this problem https://www.nopcommerce.com/boards/search?searchterms=Image+cannot+be+loaded Sometimes I had problems. I had to re-edit the file using a working file as a template. One suggestion is to upload an image to a product the normal way via Admin. Then see the file that is in then created in the directory. Then for a test try and upload only that file that which was created. At the very least this confirms you import process is correct.
Thanks Yidna, I know my method to populate the data directly and upload the files is correct because if I rename an image from something like image_abc123.jpg, to the Picture ID e.g. 0000123_0.jpg it works fine. I'm now looking at writing a script to loop through the picture data and rename each image because I think that will be the fastest way.
Thanks I might take you up on that. I successfully renamed all the images to correspond with the types of values it expects and have tested this via the product picture mapping to verify I get a result. I then wanted to input all my products and so tried inputting via the Excel Import but this generated an error "Sequence contains no matching element" which isn't too helpful. Any ideas?
Short message Sequence contains no matching element
Full message System.InvalidOperationException: Sequence contains no matching element at System.Linq.Enumerable.First[TSource](IEnumerable`1 source, Func`2 predicate) at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext() at Nop.Services.ExportImport.ImportManager.ImportProductsFromXlsx(Stream stream) in C:\andrei\nopcommerce\sources\src\Libraries\Nop.Services\ExportImport\ImportManager.cs:line 1672 at Nop.Web.Areas.Admin.Controllers.ProductController.ImportExcel(IFormFile importexcelfile) in C:\andrei\nopcommerce\sources\src\Presentation\Nop.Web\Areas\Admin\Controllers\ProductController.cs:line 2280
I've never used the excel import but the conventional advice is to export 1 product to use as a template so you can see what format it expects.
Not sure whether that's the case, but line 1672 is looking to delete categories so you may need to step through the code to see how things look at this point:
It means you are trying to find an object from a collection (using LINQ .First() method) which not exixsts in that collection. You can resolve this by replacing .First() with .FirstOrDefault(). Click here to know more about these methods.
Thanks for your input mhsjaber but for the avoidance of doubt this error occurred as I tried to input data using the Excel form generated via Product Export and then updating it with new products and going through the Import routine. Therefore, if you are correct this must be an error many have come across before.