i want to add thumbnail image for a product. so i was placed a file upload control inside "Pictures" tab.
and also i was add new column in nop_productpicture table as"ThumbnailPictureId".
its working fine if thumbnail upload control and product upload control contains files and the insert operation completed successfully.
now i have a file thumbupload control now i cliked the upload button then i m receiving this error i.e) Message = "The INSERT statement conflicted with the FOREIGN KEY constraint \"FK_Nop_ProductPicture_Nop_Picture\". The conflict occurred in database \"Nop_sample\", table \"dbo.Nop_Picture\", column 'PictureID'.\r\nThe statement has been terminated."
note: if the thumbupload control doesnot have file then i passed "0" to thumbpictureid to database. its working fine.but for existing upload control it show error even i passed "0" to PictureId.
So we have three entities: 'Product' (stored products), 'Picture' (stored pictures), and 'ProductPicture' (mapping between 'Product' and 'Picture'). When you upload a picture (standard behavior) on a product details page, two entities are created and saved: 1. 'Picture' - contains picture 2. 'ProductPicture' - tells that this picture is mapped to a certain product. It allows up to load all pictures mapped to a certains product
I presume you want to add only one thumbnail picture to a product (like it's done for categories or manufacturers). In this case you don't need 'ProductPicture'. Add 'ThumbnailPictureId' property to a 'Product' entity (not to 'ProductPicture'). Then add appropriate functionality to upload thumbnail picture on product details page. After image is uploaded and saved (into 'Nop_Picture' table), update 'ThumbnailPictureId' property to a 'Product'. Look at categories or manufactures in order to get an idea.
P.S. Don't forget to update 'Nop_ProductLoadAllPaged' stored procedure (return new 'ThumbnailPictureId' column)
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.