freddan115 Posted September 8, 2009 Share Posted September 8, 2009 Hi,I was importing my porducts wit .cvs files and it worked as expected. Then I wanted to ad a few other products extra via the "add new products" thing in the catalogue. That have always worked before flawless. Suddenly I can't create new products or import new .cvs files without error messages. see attached images.1. What has happened?2. How can I solve it?Thank you for your help! Link to comment Share on other sites More sharing options...
Radu Posted September 8, 2009 Share Posted September 8, 2009 I had the same problem with a customer - don't know what was the cause - maybe the buggy import??anyway the problem is because product and product_lang don't have the ids in sync anymoreto solve the problem open phpmyadmin:1. go to product table - and check it's max id_product -> let's say it is 30002. go to product_lang and you'll notice the max id_product is bigger than 30003. delete all entries from product_lang that are bigger than 3000donePlease submit a bug report to presta if you have the time Link to comment Share on other sites More sharing options...
codegrunt Posted September 8, 2009 Share Posted September 8, 2009 From the MYSQL error on the first screen what is happening is that a non-unique value is attempting to be inserted into a column that is set as being unique. Unfortunately, there is not enough detail in that error message to know which table for sure was affected as it could be a case of an invalid CSV file causing columns getting stuffed into the wrong spots in which case the product name shown may not actually be in the product name column as far as Prestashop is concerned. It depends on your technical level here how best to troubleshoot things. If you want to know what specific field is causing the above error you need to edit:admin/tabs/AdminImport.phpand then search for "cannot be added". You will see lot of lines like this where a given field is attempted to be inserted into the database and then an error raised if that fails: $this->_errors[] = $categoryToCreate->name[$defaultLanguageId].(isset($categoryToCreate->id) ? ' ('.$categoryToCreate->id.')' : '').' '.Tools::displayError('cannot be saved'); You should add a prefix in there so it is clear which section of the code is raising the error. Something like this: $this->_errors[] = $categoryToCreate->name[$defaultLanguageId].(isset($categoryToCreate->id) ? ' ('.$categoryToCreate->id.')' : '').' '.Tools::displayError('cannot be saved [category: '.__LINE__.']'); That will let you know in the error message that it was a category create that failed and in what line in the script. Once you know where exactly it is failing you can then figure out what table is having the issue and then look at it with phpMyAdmin to see what might be going on here.Cheers Link to comment Share on other sites More sharing options...
freddan115 Posted September 8, 2009 Author Share Posted September 8, 2009 Thanks for your advice!My biggest issue here is that I don't have any experience with phpmyadmin. Can I do this with my ftp server? Maybe change some .php files?Thank you again for your time. Link to comment Share on other sites More sharing options...
codegrunt Posted September 8, 2009 Share Posted September 8, 2009 Most commercial web hosts have a global phpMyAdmin install accessible via you control panel. phpMyAdmin is a web interface for manipulating MySQL databases. So the assumption here is that you have at least a basic understanding of MySQL, enough to take a look at a table and see if certain things are obviously amiss. For example, a corrupted table could be the issue or you could have something funny in a given column or you could have a table that has a small limit on autoincrement IDs and you have exhausted the number of rows you can insert or something else like that that has led to this specific issue. Basically you are needing to sort out what query is failing and then figure out why that is happening. There might also be a debug option in Prestashop to show all queries sent to MySQL but I have not dug deep enough myself to know for sure.If you do not have much data in the system you could also try clearing out the product database (and associated things like manufacturers) to see if that corrects the problem.Cheers Link to comment Share on other sites More sharing options...
freddan115 Posted September 8, 2009 Author Share Posted September 8, 2009 I have now replaced the code with the one provided by you. I simply took the adminimport.php from my ftp server and located the code and added ...__LINE__... etc. Nothing happened so I guess I have to figure out how to use phpmyadmin. I do not have that many products actually so maybe I should just delete them all. I would like to know what had happened though so I don't make the same "mistake" again. Link to comment Share on other sites More sharing options...
codegrunt Posted September 8, 2009 Share Posted September 8, 2009 The code you added (assuming you caught all the spots) would have changed the error messages during a CSV import only. What happens when you try to run a CSV import?Cheers Link to comment Share on other sites More sharing options...
freddan115 Posted September 8, 2009 Author Share Posted September 8, 2009 I get the same error again. Link to comment Share on other sites More sharing options...
freddan115 Posted September 8, 2009 Author Share Posted September 8, 2009 I got my phpmyadmin to work. I will try your other suggestions now Okej, I have tryed to follow the 3 steps provided earlier. But I don't understand what I am supposed to do. The php admin is mor advanced then I thought... Link to comment Share on other sites More sharing options...
codegrunt Posted September 8, 2009 Share Posted September 8, 2009 The fact that the error message still does not include anything useful makes me think you did not catch all instances of "cannot be saved" in the import script. I just did a command line search and that is the only file in the latest version of Prestahop that has that string of text. Make sure you catch all of them and change the line to reflect what the code is updating (i.e. if it is updating the supplier, change the extra text to "supplier" instead of category):$this->_errors[] = $supplier->name.(isset($supplier->id) ? ' ('.$supplier->id.')' : '').' '.Tools::displayError('cannot be saved');becomes:$supplier->name.(isset($supplier->id) ? ' ('.$supplier->id.')' : '').' '.Tools::displayError('cannot be saved [supplier: '.__LINE__.']');etc.The goal is to figure out what query is failing and that requires nailing down where in the import script things are going wrong.Cheers Link to comment Share on other sites More sharing options...
freddan115 Posted September 8, 2009 Author Share Posted September 8, 2009 [supplier: ‘.LINE.’]’);[category: '.__LINE__.']');2 questions.Which one of the above is the correct solution. Should the word change before LINE, like one I wrote would be [info: ‘.LINE.’]’);please help me sort this out. Link to comment Share on other sites More sharing options...
freddan115 Posted September 8, 2009 Author Share Posted September 8, 2009 I have located the problem to be with name* column. But i dont know how to solv it Link to comment Share on other sites More sharing options...
VIXUS Posted November 10, 2009 Share Posted November 10, 2009 I had the exact same problem... import worked and suddenly don't anymore.I resolved that problem with backup of an older database.But i still dont know what caused the problem. Link to comment Share on other sites More sharing options...
Radu Posted November 10, 2009 Share Posted November 10, 2009 a problem can be, see my message above:anyway the problem is because product and product_lang don’t have the ids in sync anymoreto solve the problem open phpmyadmin:1. go to product table – and check it’s max id_product -> let’s say it is 30002. go to product_lang and you’ll notice the max id_product is bigger than 30003. delete all entries from product_lang that are bigger than 3000 Link to comment Share on other sites More sharing options...
Recommended Posts