magento can't reindex product attributes - mysql

When I run Reindex from Index Management it gives error "Cannot initialize the indexer process."
So based on following article here
http://jasonehmke.com/ecommerce/cannot-initialize-the-indexer-process-in-magento/
I ran
php -f indexer.php reindexall
Which gave following output:
Product Prices index was rebuilt successfully
Catalog URL Rewrites index was rebuilt successfully
Product Flat Data index was rebuilt successfully
Category Flat Data index was rebuilt successfully
Category Products index was rebuilt successfully
Catalog Search Index index was rebuilt successfully
Stock Status index was rebuilt successfully
Tag Aggregation Data index was rebuilt successfully
Product Attributes index process unknown error:
exception 'PDOException' with message 'SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '65-542-1-65' for key 'PRIMARY'' in /home/bizzosph/public_html/lib/Zend/Db/Statement/Pdo.php:228
Next exception 'Zend_Db_Statement_Exception' with message 'SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '65-542-1-65' for key 'PRIMARY'' in /home/bizzosph/public_html/lib/Zend/Db/Statement/Pdo.php:234
Any idea how do I fix this? It does not tell me what table has duplicate entry.
Thanks

I'm sure you've moved on since posting this question, but since it has ~2500 views (and having this answer here would have helped me), I'll add the resolution I found. This does not require truncating any database tables or even any direct SQL queries:
Last night, I was having the same problem. My error was the same as yours (except for the numbers which refer to the product and attribute causing the problem). If you go and re-save that product in the Manage Products section of the admin (no need to change it, just open it to edit and click save), it will solve the problem - but you very likely have more products that will bring additional similar errors.
In my case, it wasn't just a problem with 1 product there were several hundred products causing errors (each one saved brought up a new one). And it wasn't all with the same attribute (I'd updated multiple attributes across a database of over 4,000 products in my last import).
Since everything seemed to actually be in the database correctly (since re-saving seemed to be fixing it and giving the proper data to the final saved product), I had an idea.
Why not export all 4k products, and then re-import the same file without modification and see if that clears it.
It worked!
tl;dr: If you're having this problem with multiple products needing to be re-saved, export your whole inventory (or the relevant section if you can segment in a useful way), and re-import the same file with no modifications.
I'm using Magento v 1.9.0.1

Try first to clean Magento cache. If no success, run official DB repair tool

The solution is to run the following MySQL queries:
TRUNCATE TABLE `catalog_product_flat_1`;
TRUNCATE TABLE `catalog_product_flat_2`;
TRUNCATE TABLE `catalog_product_flat_3`;

Related

Microsoft Access linked table (ASE) with trigger error

I have in Microsoft Access a linked table to an ASE Server.
On the server side, the table has no primary key or identity columns.
And has a trigger on insert that validates new entries, so that when the entry is not validated it deletes the entry from the table and writes to "table"_ERR to let the users know what error was produced.
When linking it to Access a composite key is created using 10 columns.
I have this same setup in 10 different tables (all with triggers all linked to Access)
In this particular table when trying to insert/append records to the table through Access i always get the error message:
Single-row update/delete affected more than one row of a linked table. Unique index contains duplicate values.
This error occurs when both table and table_ERR are empty and i'm only trying to insert 1 record.
If I disable the trigger i have no problem inserting records through Access
I have similar triggers in other tables that are working correctly.
What can be causing this issue and does anyone know how to solve this?
I have read that MS Access can mess up the ##identity, even so none of the solutions presented online seem to work.
links : https://groups.google.com/forum/#!msg/microsoft.public.sqlserver.programming/McHdRpPKMhs/SlyObU8w7JMJ
Stop Access from using wrong identity when appending to linked table on SQL server
Thanks in advance.
EDIT: if i try to insert the records directly from a management software (like Aqua Data Studio) there are no erros
Without knowing more specifics about your data itself, it is difficult to say why this might be happening.
However, it sounds like in this specific instance for this specific linked table, your 10 columns are not unique enough to prevent non-distinct rows from being selected.
Suggested fixes:
Add a primary key. Honestly, probably the best and easiest choice.
If for some reason you cannot add a new column to (or alter) your table; you may be able to re-link your table, and re-choose your 10 columns so that they are more unique.
Beyond that, I think we would need more information.
Just out of curiousity, what is the reason for having no key?

Integrity error django

I was using sqlite3 for my database in django project and then I decided to change it to mysql engine. I changed everything in the settings.py correctly, and in order not to lose the db I dumped my sqlite one to text and I changed every " with `, removed Commit and all things related to sqlite3. I executed the dump file on mysql and everything was added perfectly. However, when I try to add a cateogory in a table called categories.
I get this error message
IntegrityError at /admin/red_carpet/category/
(1062, "Duplicate entry '0' for key 1")
I thought the key is duplicate wich what is the error saying. I looked at the "id" column to see it is structure I found that the id column is "NOT NULL". There was no auto increment added to that column so I added it and tried to do category from admin page I got the same error I looked again at the structure and then I added the query that the auto_increment shouldn't start from 0 but should start from last value which was 6. Then I added the category from the django admin again but I still get the same error, looked again at the structure and especially in the indexes part in phpmyadmin I found that line
Keyname Type Cardinality Action Field
PRIMARY PRIMARY 9 id
For me, everything looks good and actually when I add value through django admin I get it added though I get the same error message
IntegrityError at /admin/red_carpet/category/
(1062, "Duplicate entry '0' for key 1")
I really can't understand why is this problem !!!! Anyone have been thorough this before !! ??
PS: I get the same error message when I try to remove something. For example, if I am removing a cateogory I get the exat error message though when I look at the db I found that the category has been removed !!
One way to prevent cross-db issues would be to use fixtures, e.g. dump and load your data in (db-agnostic) json format:
see dump data command and
what is a fixture
from the django documentation.

Magento re-index, cannot create table

I'm trying to re-index the category flat data, but I am always met with the same error:
There was a problem with reindexing process. Error Message: SQLSTATE[HY000]: General error: 1005 Can't create table 'xxx.catalog_category_flat_store_6' (errno: 121)
The table doesn't exist, there is a 1 and a 7. Not sure if that makes a difference?
After running the query manually through phpMyAdmin, I am met with the MySQL error 121. I've checked around and this would suggest the names of the foreign keys trying to be created already exist. I've listed all foreign keys in the DB right now, and they don't exist at all.
I've also tried running SHOW ENGINE INNODB STATUS on the DB for more information, but we don't have the rights to view that apparently.
After getting the priv's updated so we could run SHOW INNODB STATUS, we discovered that we already had an existing index that was attempting to be duplicated with this new table. This stemmed from us backing up an older version of the table that was trying to be created. Deleting that copy of the table enabled Magento to re-index properly and solved our problem.
Try logging the sql commands and debug what its trying to do by executing them manually. On the index process, normally there is a command that clears a table, and another to recreate it.
Edit /magentoRoot/lib/Varien/Db/Adapter/Pdo/Mysql.php and change $_debug to true and note the $_debugFile location (should be var/debug/pdo_mysql.log)
Its best to edit the file in vi, have a browser open to reindex JUST the category data, save the file in vi :w! and then run the indexer then change the debug back to false.
Then go read the log. It may help.

Duplicate entry key on import

We’re facing a few problems when trying to update product in Magento at the moment.
What we’ve done so far to eliminate any problems:
Wiped all products from the database
Imported all products
Everything was working on site great, then we’ve seen something that needs updating in all of our products so we’re trying to re-import our products to update the existing products.
This is where we’re experiencing some issues:
Importing existing product with an update produces error: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '1-0-1' for key 'PRIMARY'
This happens on the first record it process
Does anyone have any ideas on why this is happening? what it the error message actually saying?
How are you updating the products? Are you using the product import or dataflow? There is a primary key(s) on the table. The manner in which you are doing the import is trying to add the products and not update them. Since the primary key must be unique, you are trying to put a new record in with an existing primary key. That's what the SQL error is...
Go into the Magento admin, under System > Import/Export > Export. That will get you all the data in the correct format. Make your changes. Then go back and do an import.
On the import screen select 'Replace Complex Data' as the import behavior. I would backup the database first and test it out on a dev environment, but that is the correct way to handle it.

MySQL Error: #1062 - Duplicate entry 'rewrite_rules' for key 2

I am trying to restore a WordPress MySQL DB from a recent backup since my site (wp-admin) became unusable after I changed the site_url incorrectly. I am trying to reinstall the entire site again but need to reinstall the DB. The problem is my wp_options table will not upload via PHPmyAdmin. The error I get is:
#1062 - Duplicate entry 'rewrite_rules' for key 2
I know little about MySQL but this seems odd as the DB was working happily before I deleted it to attempt the reinstall.
Can anyone please advise?
The error means that you are inserting data into a column with must be unique.
In this case you may be importing data that has 'rewrite_rules' as a data item in a row into a table that already has 'rewrite_rules' as a data item in a row in a column that as been marked as unique.
If you are reinstalling wordpress from scratch and are trying to import the old data over the top you need to take a few steps first. See the link below for some instructions
http://www.ehow.com/how_4579080_export-import-wordpress-blog.html