News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Image - Replace Thumb sql error

Started by Shimon Hirschhorn, May 16, 2016, 14:03:40 PM

Previous topic - Next topic

Shimon Hirschhorn

Hello,

I am getting a sql error when I try to replace the thumbnail image on an item.

1062 Duplicate entry '0-5428' for key 'virtuemart_product_id' SQL=INSERT INTO `jos_virtuemart_product_medias` (`virtuemart_product_id`,`virtuemart_media_id`,`ordering`) VALUES ('','5428','1')

Any suggestions what I can do to repair this ?

Thanks

tommo27

Hi Shimon,

Without looking into it more, it would appear that the SQL you're running should be an update statement, not insert.  The error you're getting tells you that the unique ID you're trying to insert into the database has already being used (it's already in there) and you can only use each unique ID once only.  The statement below will accomplish the task that needs to be done (updating the image thumbnail field):

UPDATE jos_virtuemart_product_medias SET virtuemart_media_id = '5428', ordering='1' WHERE virtuemart_product_id = '<ID of the product to be updated>'

If possible, turn on debug mode within the system section of global configuration and re-run the action that generates this error.  You should notice this time a stack trace which will allow us to follow the the calls and find out what we need to change.

Are you getting this error after an update, modification or extension installation etc or is this custom code you have written?