Jump to content

prestashop 1.6.1.6 Error adding image to new product = Duplicate entry ps_image


c64girl

Recommended Posts

It seems my prestashop broke it was working ok untill now. I have an error adding images to new products the permission to img folder files and folders inside are ok and i dont know what seems to be a problem.

 

 

I have this error when adding an image and dev error is true:

 

JSON.parse: unexpected character at line 1 column 1 of the JSON data

 

 

 

 

Firebug says:

Duplicate entry '176-1' for key 'id_product_cover'

INSERT INTO `ps_image` (`id_product`, `position`, `cover`, `hover`) VALUES ('176', '2', '1', '0')
<div class="alert alert-danger">
            <button type="button" class="close" data-dismiss="alert">×</button>
                            Duplicate entry '176-1' for key 'id_product_cover'<br /><br /><pre>INSERT INTO `ps_image` (`id_product`, `position`, `cover`, `hover`) VALUES ('176', '2', '1', '0')</pre>
                    </div>

 

 

My mysql table ps_image looks like this:

 

image.jpg

Edited by c64girl (see edit history)
Link to comment
Share on other sites

The error says that you are trying to add a new cover image to a product that already has an exist cover image.  A product can only have 1 cover image.

 

Did you browse/search your ps_image database table to see if this is a true statement?

 

Hey, yes that is a true statement but when i delete the cover image that is in ps_image and try to add picture again i get the same error. When i create a new product and want to add a image i get the same error duplicated : (

 

What i noticed is when i clear table ps_image the problem is fixed but this clearing delete previous products images :(

 

 

Thank You for reply

Edited by c64girl (see edit history)
Link to comment
Share on other sites

Ok i fixed the problem. My friend helped me it was a 3 days testing mess...

 

 

What i did:

 

1. Changed the ps_image to ps_image3.

2. Created the table with this structure:

-- phpMyAdmin SQL Dump
-- version 4.2.12deb2+deb8u1
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Czas generowania: 14 Sie 2016, 21:13
-- Wersja serwera: 10.1.14-MariaDB-1~jessie
-- Wersja PHP: 5.6.22-0+deb8u1

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";

--
-- Baza danych: `yourdatabase`
--

-- --------------------------------------------------------

--
-- Struktura tabeli dla tabeli `ps_image`
--

CREATE TABLE IF NOT EXISTS `ps_image` (
`id_image` int(10) unsigned NOT NULL,
  `id_product` int(10) unsigned NOT NULL,
  `position` smallint(2) unsigned NOT NULL,
  `cover` tinyint(1) unsigned DEFAULT NULL,
  `hover` tinyint(1) NOT NULL
) ENGINE=InnoDB AUTO_INCREMENT=1719 DEFAULT CHARSET=utf8;

--
-- Indeksy dla zrzutów tabel
--

--
-- Indexes for table `ps_image`
--
ALTER TABLE `ps_image`
 ADD PRIMARY KEY (`id_image`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT dla tabeli `ps_image`
--
ALTER TABLE `ps_image`
MODIFY `id_image` int(10) unsigned NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=1719;

3. I copied data to that new table i created.

4. I changed the AUTO_INCREMENT to 1700 i had before 1500. So i added 200 to be sure nothing f*up

 

 

Now its working it seems the table after updating from 1.6.0.1 to 1.6.1.6 damaged somehow...

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...