Error message: 1062 Duplicate entry '403518'​ for key 'PRIMARY'

  • Posts: 87
  • Thank you received: 5
  • Hikashop Business
4 years 5 months ago #321115

-- HikaShop version -- : 4.3.0
-- Joomla version -- : Joomla! 3.9.19 Stable [ Amani ] 2-June-2020
-- PHP version -- : 7.3.18
-- Error-message(debug-mod must be tuned on) -- : 1062 Duplicate entry '403518'​ for key 'PRIMARY'

This issue just cropped up. Whenever I try to add a new price to an item and try to save the product I get this error message:

1062 Duplicate entry '403518'​ for key 'PRIMARY'

It does not matter if I make a new product or edit an existing one. The product itself is saved but I cannot add a price.

I think this is a database error, but I don't know how to solve it.


EDIT:
I just checked the hikashop_price table in my database (because I think this is where the problem comes from). There is indeed already an entry with price_id 403518 in there. But this is not the highest entry. The highest price_id in my table is actually 404277, so i do not understand why Hikashop is trying to same the price_id for a new product as lower than the latest added price_id. Shouldn't the price_id be automatically incremented?

Last edit: 4 years 5 months ago by Foxworks.

Please Log in or Create an account to join the conversation.

  • Posts: 87
  • Thank you received: 5
  • Hikashop Business
4 years 5 months ago #321122

I think I fixed the issue. In PHPMyAdmin for my hosting I went into the hikashop_price table and in the table options I changed the AUTO_INCREMENT setting to the current highest price_id +1. I can now save new prices again.

If anyone from Hikashop reads this, could you please let me know if this is indeed a correct fix for this issue?
I would also like to know how this could have happened and what I can do to prevent this from happening again.

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
4 years 5 months ago #321127

Hi,

The only ways I can see are:
- that the auto_increment value of the hikashop_price table has been modified to be lower than the max price_id. That would require manual intervention in phpmyadmin.
-that prices were injected in the hikashop_price table with the price_id already provided and bigger than the auto_increment at some point in the past. And it was fine, until the auto_increment catched up with these price_ids. Such injection could be done by some importing tool / script, or maybe some backup restore system gone awry. I'm suspecting that these price entries have been there for a long while.

Please Log in or Create an account to join the conversation.

Time to create page: 0.055 seconds
Powered by Kunena Forum