Image Upload in 4.2

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
4 anni tempo fa
[email protected] wrote:
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.


put a breakpoint in ImportManager.cs on this line 1668 to see what you have to match for importedCategories


//delete product categories
var deletedProductCategories = categories.Where(categoryId => !importedCategories.Contains(categoryId))
    .Select(categoryId => product.ProductCategories.First(pc => pc.CategoryId == categoryId));
4 anni tempo fa
I went about things a different way. I removed image filepaths from the Excel and inserted products only. I then renamed images to what appeared to be the nopCommerce style e.g. 0000123_product-seo-friendly-name.jpeg and generated thumbnail variants in 64, 75, 100, 415 1nd 550 px widths e.g. 0000123_product-seo-friendly-name_64.jpeg. These images are in the Picture data table using the above example that would be ID 123, and the relationship is mapped in the Product Picture Mapping Table but most don't work! Clearly I have a naming conflict, so, rechecking that for now rather than return to  your most welcome suggestions.
4 anni tempo fa
when a picture is first uploaded to wwwroot/images it has the format (note the _0 before the filetype):
var fileName = $"{pictureId:0000000}_0.{lastPart}";


then when the product is viewed for the first time on the frontend the thumbnails will be created (if they don't already exist) with the SEO name in the wwwroot/images/thumbs directories according to your settings

try renaming a test image to wwwroot/images/0000123_0.jpeg, then view that product on the frontend to see what happens
4 anni tempo fa
Would I be right in thinking the IsNew value in Picture should be set to True?
4 anni tempo fa
I didn't when I bulk imported my pictures, I set isNew = 0 and had no issues.  If you don't already have generated thumbnails then it should have no effect.

isNew is used in various places during inserting/updating images, but where you're concerned is it deletes existing thumbs when the frontend calls for the image url

check the GetPictureUrl method in PictureService.cs
4 anni tempo fa
I'm just not getting this at all. Let me update you on what I've most recently done.
1. Generated images named 0001234_0.jpeg where 123 is the corresponding Id in Picture
2. Upload images to wwwroot\images
3. Generated records to relate Picture.Id and Product.Id in Product_Picture_Mapping
4. Restarted site in IIS
5. Viewed site to find only the default "No Image" showing in all but the ones where my previously created thumbnails had worked
6. Checked in to admin and noted that a few show a x as missing image yet when I check the source code and I can see the image 0000260_tee-#1-eaglemuscles-lkntht_75.jpeg as requested is indeed in the images\thumbs folder, realised the # would cause a problem and so corrected (this came from the product name), it now works but most still show the default No Image.
7. I'm guessing this is down to something daft like spurious spaces in the SeoFilename so tomorrow I'll do some random cross checking and see what I can find.
4 anni tempo fa
[email protected] wrote:

7. I'm guessing this is down to something daft like spurious spaces in the SeoFilename so tomorrow I'll do some random cross checking and see what I can find.


Everything looks correct, but it's worth checking the above.  I had a vendor with '/' in their descriptions which made for all sorts of fun with subdirectories being created.

Do you have direct access to your db?  I'm curious what you have in Picture for an example product without image


SELECT *
FROM Picture pic
INNER JOIN Product_Picture_Mapping map
  ON pic.Id = map.PictureId
WHERE map.ProductId = xxxxx  --eg 123
4 anni tempo fa
Thanks no problems with SQL that is my strength. This is loaded on a Virtual Server, hosted on a physical server that I have so I have complete access to all at the backend.
4 anni tempo fa
It was spurious chars such as carriage returns within the string. Couldn't be seen viewing t he SQL table but affected the results insofar as world1-word2-word3 was in effect word1-word2-'char(10)'word3
4 anni tempo fa
nice find!
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.