Magento indexing is failing, SQLSTATE[23000]: Integrity constraint violation The Next CEO of...

Opposite of a diet

What is the point of a new vote on May's deal when the indicative votes suggest she will not win?

How to count occurrences of text in a file?

Does it take more energy to get to Venus or to Mars?

How to Reset Passwords on Multiple Websites Easily?

How can I open an app using Terminal?

How to write the block matrix in LaTex?

The King's new dress

Would this house-rule that treats advantage as a +1 to the roll instead (and disadvantage as -1) and allows them to stack be balanced?

Natural language into sentence logic

Only print output after finding pattern

Term for the "extreme-extension" version of a straw man fallacy?

Should I tutor a student who I know has cheated on their homework?

Increase performance creating Mandelbrot set in python

How can I quit an app using Terminal?

Why did we only see the N-1 starfighters in one film?

How do I construct this japanese bowl?

Implement the Thanos sorting algorithm

% symbol leads to superlong (forever?) compilations

How can I get through very long and very dry, but also very useful technical documents when learning a new tool?

Text adventure game code

Example of a Mathematician/Physicist whose Other Publications during their PhD eclipsed their PhD Thesis

Why didn't Theresa May consult with Parliament before negotiating a deal with the EU?

Grabbing quick drinks



Magento indexing is failing, SQLSTATE[23000]: Integrity constraint violation



The Next CEO of Stack OverflowCan't re-index Category Products - SQLSTATE[23000]: Integrity constraint violation: 1452Magento 1.8 reindex allFix error “There was a problem with reindexing process.” or “Cannot initialize the indexer process.”Index Management ProblemProduct Attributes could not be reindexedSQLSTATE[42S02]: Base table or view not found: 1146 Table 'core_store' doesn't existReindex catalog categories url issueError when moving Magento File to a different domainSQLSTATE[HY000] : General error: 2013 Lost connection to MySQL server during query in MagentoInvalid method Yoast_MetaRobots_Block_Catalog_Product_View:MySQL cron_schedule update problem












3















For some reason Magento indexing is failing, we haven't changed anything in the website.... And that is the weird thing! The error in shell using indexer.php:



$ php indexer.php --reindex catalog_product_flat
Product Flat Data index process unknown error:
exception 'PDOException' with message 'SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`**********_db`.`#sql-649_47012`, CONSTRAINT `FK_CAT_PRD_FLAT_1_ENTT_ID_CAT_PRD_ENTT_ENTT_ID` FOREIGN KEY (`entity_id`) REFERENCES `catalog_product_entity` (`entity_id`) ON DELETE CASCADE ON U)' in /home/**********/domains/***********nna.nl/public_html/lib/Zend/Db/Statement/Pdo.php:228
Stack trace:
#0 /home/**********/domains/***********nna.nl/public_html/lib/Zend/Db/Statement/Pdo.php(228): PDOStatement->execute(Array)
#1 /home/**********/domains/***********nna.nl/public_html/lib/Varien/Db/Statement/Pdo/Mysql.php(110): Zend_Db_Statement_Pdo->_execute(Array)
#2 /home/**********/domains/***********nna.nl/public_html/lib/Zend/Db/Statement.php(300): Varien_Db_Statement_Pdo_Mysql->_execute(Array)
#3 /home/**********/domains/***********nna.nl/public_html/lib/Zend/Db/Adapter/Abstract.php(479): Zend_Db_Statement->execute(Array)
#4 /home/**********/domains/***********nna.nl/public_html/lib/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('ALTER TABLE `ca...', Array)
#5 /home/**********/domains/***********nna.nl/public_html/lib/Varien/Db/Adapter/Pdo/Mysql.php(419): Zend_Db_Adapter_Pdo_Abstract->query('ALTER TABLE `ca...', Array)
#6 /home/**********/domains/***********nna.nl/public_html/lib/Varien/Db/Adapter/Pdo/Mysql.php(340): Varien_Db_Adapter_Pdo_Mysql->query('ALTER TABLE `ca...')
#7 /home/**********/domains/***********nna.nl/public_html/lib/Varien/Db/Adapter/Pdo/Mysql.php(2569): Varien_Db_Adapter_Pdo_Mysql->raw_query('ALTER TABLE `ca...')
#8 /home/**********/domains/***********nna.nl/public_html/app/code/core/Mage/Catalog/Model/Resource/Product/Flat/Indexer.php(816): Varien_Db_Adapter_Pdo_Mysql->addForeignKey('FK_CAT_PRD_FLAT...', 'catalog_product...', 'entity_id', 'catalog_product...', 'entity_id', 'CASCADE', 'CASCADE')
#9 /home/**********/domains/***********nna.nl/public_html/app/code/core/Mage/Catalog/Model/Resource/Product/Flat/Indexer.php(1390): Mage_Catalog_Model_Resource_Product_Flat_Indexer->prepareFlatTable(1)
#10 /home/**********/domains/***********nna.nl/public_html/app/code/core/Mage/Catalog/Model/Product/Flat/Indexer.php(296): Mage_Catalog_Model_Resource_Product_Flat_Indexer->reindexAll()
#11 /home/**********/domains/***********nna.nl/public_html/app/code/core/Mage/Catalog/Model/Product/Indexer/Flat.php(336): Mage_Catalog_Model_Product_Flat_Indexer->reindexAll()
#12 /home/**********/domains/***********nna.nl/public_html/app/code/core/Mage/Index/Model/Process.php(209): Mage_Catalog_Model_Product_Indexer_Flat->reindexAll()
#13 /home/**********/domains/***********nna.nl/public_html/app/code/core/Mage/Index/Model/Process.php(255): Mage_Index_Model_Process->reindexAll()
#14 /home/**********/domains/***********nna.nl/public_html/shell/indexer.php(160): Mage_Index_Model_Process->reindexEverything()
#15 /home/**********/domains/***********nna.nl/public_html/shell/indexer.php(200): Mage_Shell_Compiler->run()
#16 {main}









share|improve this question

























  • Check my answer on this link magento.stackexchange.com/questions/105393/… Hope this will help you

    – Asish Hira
    Mar 14 '16 at 7:27
















3















For some reason Magento indexing is failing, we haven't changed anything in the website.... And that is the weird thing! The error in shell using indexer.php:



$ php indexer.php --reindex catalog_product_flat
Product Flat Data index process unknown error:
exception 'PDOException' with message 'SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`**********_db`.`#sql-649_47012`, CONSTRAINT `FK_CAT_PRD_FLAT_1_ENTT_ID_CAT_PRD_ENTT_ENTT_ID` FOREIGN KEY (`entity_id`) REFERENCES `catalog_product_entity` (`entity_id`) ON DELETE CASCADE ON U)' in /home/**********/domains/***********nna.nl/public_html/lib/Zend/Db/Statement/Pdo.php:228
Stack trace:
#0 /home/**********/domains/***********nna.nl/public_html/lib/Zend/Db/Statement/Pdo.php(228): PDOStatement->execute(Array)
#1 /home/**********/domains/***********nna.nl/public_html/lib/Varien/Db/Statement/Pdo/Mysql.php(110): Zend_Db_Statement_Pdo->_execute(Array)
#2 /home/**********/domains/***********nna.nl/public_html/lib/Zend/Db/Statement.php(300): Varien_Db_Statement_Pdo_Mysql->_execute(Array)
#3 /home/**********/domains/***********nna.nl/public_html/lib/Zend/Db/Adapter/Abstract.php(479): Zend_Db_Statement->execute(Array)
#4 /home/**********/domains/***********nna.nl/public_html/lib/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('ALTER TABLE `ca...', Array)
#5 /home/**********/domains/***********nna.nl/public_html/lib/Varien/Db/Adapter/Pdo/Mysql.php(419): Zend_Db_Adapter_Pdo_Abstract->query('ALTER TABLE `ca...', Array)
#6 /home/**********/domains/***********nna.nl/public_html/lib/Varien/Db/Adapter/Pdo/Mysql.php(340): Varien_Db_Adapter_Pdo_Mysql->query('ALTER TABLE `ca...')
#7 /home/**********/domains/***********nna.nl/public_html/lib/Varien/Db/Adapter/Pdo/Mysql.php(2569): Varien_Db_Adapter_Pdo_Mysql->raw_query('ALTER TABLE `ca...')
#8 /home/**********/domains/***********nna.nl/public_html/app/code/core/Mage/Catalog/Model/Resource/Product/Flat/Indexer.php(816): Varien_Db_Adapter_Pdo_Mysql->addForeignKey('FK_CAT_PRD_FLAT...', 'catalog_product...', 'entity_id', 'catalog_product...', 'entity_id', 'CASCADE', 'CASCADE')
#9 /home/**********/domains/***********nna.nl/public_html/app/code/core/Mage/Catalog/Model/Resource/Product/Flat/Indexer.php(1390): Mage_Catalog_Model_Resource_Product_Flat_Indexer->prepareFlatTable(1)
#10 /home/**********/domains/***********nna.nl/public_html/app/code/core/Mage/Catalog/Model/Product/Flat/Indexer.php(296): Mage_Catalog_Model_Resource_Product_Flat_Indexer->reindexAll()
#11 /home/**********/domains/***********nna.nl/public_html/app/code/core/Mage/Catalog/Model/Product/Indexer/Flat.php(336): Mage_Catalog_Model_Product_Flat_Indexer->reindexAll()
#12 /home/**********/domains/***********nna.nl/public_html/app/code/core/Mage/Index/Model/Process.php(209): Mage_Catalog_Model_Product_Indexer_Flat->reindexAll()
#13 /home/**********/domains/***********nna.nl/public_html/app/code/core/Mage/Index/Model/Process.php(255): Mage_Index_Model_Process->reindexAll()
#14 /home/**********/domains/***********nna.nl/public_html/shell/indexer.php(160): Mage_Index_Model_Process->reindexEverything()
#15 /home/**********/domains/***********nna.nl/public_html/shell/indexer.php(200): Mage_Shell_Compiler->run()
#16 {main}









share|improve this question

























  • Check my answer on this link magento.stackexchange.com/questions/105393/… Hope this will help you

    – Asish Hira
    Mar 14 '16 at 7:27














3












3








3


1






For some reason Magento indexing is failing, we haven't changed anything in the website.... And that is the weird thing! The error in shell using indexer.php:



$ php indexer.php --reindex catalog_product_flat
Product Flat Data index process unknown error:
exception 'PDOException' with message 'SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`**********_db`.`#sql-649_47012`, CONSTRAINT `FK_CAT_PRD_FLAT_1_ENTT_ID_CAT_PRD_ENTT_ENTT_ID` FOREIGN KEY (`entity_id`) REFERENCES `catalog_product_entity` (`entity_id`) ON DELETE CASCADE ON U)' in /home/**********/domains/***********nna.nl/public_html/lib/Zend/Db/Statement/Pdo.php:228
Stack trace:
#0 /home/**********/domains/***********nna.nl/public_html/lib/Zend/Db/Statement/Pdo.php(228): PDOStatement->execute(Array)
#1 /home/**********/domains/***********nna.nl/public_html/lib/Varien/Db/Statement/Pdo/Mysql.php(110): Zend_Db_Statement_Pdo->_execute(Array)
#2 /home/**********/domains/***********nna.nl/public_html/lib/Zend/Db/Statement.php(300): Varien_Db_Statement_Pdo_Mysql->_execute(Array)
#3 /home/**********/domains/***********nna.nl/public_html/lib/Zend/Db/Adapter/Abstract.php(479): Zend_Db_Statement->execute(Array)
#4 /home/**********/domains/***********nna.nl/public_html/lib/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('ALTER TABLE `ca...', Array)
#5 /home/**********/domains/***********nna.nl/public_html/lib/Varien/Db/Adapter/Pdo/Mysql.php(419): Zend_Db_Adapter_Pdo_Abstract->query('ALTER TABLE `ca...', Array)
#6 /home/**********/domains/***********nna.nl/public_html/lib/Varien/Db/Adapter/Pdo/Mysql.php(340): Varien_Db_Adapter_Pdo_Mysql->query('ALTER TABLE `ca...')
#7 /home/**********/domains/***********nna.nl/public_html/lib/Varien/Db/Adapter/Pdo/Mysql.php(2569): Varien_Db_Adapter_Pdo_Mysql->raw_query('ALTER TABLE `ca...')
#8 /home/**********/domains/***********nna.nl/public_html/app/code/core/Mage/Catalog/Model/Resource/Product/Flat/Indexer.php(816): Varien_Db_Adapter_Pdo_Mysql->addForeignKey('FK_CAT_PRD_FLAT...', 'catalog_product...', 'entity_id', 'catalog_product...', 'entity_id', 'CASCADE', 'CASCADE')
#9 /home/**********/domains/***********nna.nl/public_html/app/code/core/Mage/Catalog/Model/Resource/Product/Flat/Indexer.php(1390): Mage_Catalog_Model_Resource_Product_Flat_Indexer->prepareFlatTable(1)
#10 /home/**********/domains/***********nna.nl/public_html/app/code/core/Mage/Catalog/Model/Product/Flat/Indexer.php(296): Mage_Catalog_Model_Resource_Product_Flat_Indexer->reindexAll()
#11 /home/**********/domains/***********nna.nl/public_html/app/code/core/Mage/Catalog/Model/Product/Indexer/Flat.php(336): Mage_Catalog_Model_Product_Flat_Indexer->reindexAll()
#12 /home/**********/domains/***********nna.nl/public_html/app/code/core/Mage/Index/Model/Process.php(209): Mage_Catalog_Model_Product_Indexer_Flat->reindexAll()
#13 /home/**********/domains/***********nna.nl/public_html/app/code/core/Mage/Index/Model/Process.php(255): Mage_Index_Model_Process->reindexAll()
#14 /home/**********/domains/***********nna.nl/public_html/shell/indexer.php(160): Mage_Index_Model_Process->reindexEverything()
#15 /home/**********/domains/***********nna.nl/public_html/shell/indexer.php(200): Mage_Shell_Compiler->run()
#16 {main}









share|improve this question
















For some reason Magento indexing is failing, we haven't changed anything in the website.... And that is the weird thing! The error in shell using indexer.php:



$ php indexer.php --reindex catalog_product_flat
Product Flat Data index process unknown error:
exception 'PDOException' with message 'SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`**********_db`.`#sql-649_47012`, CONSTRAINT `FK_CAT_PRD_FLAT_1_ENTT_ID_CAT_PRD_ENTT_ENTT_ID` FOREIGN KEY (`entity_id`) REFERENCES `catalog_product_entity` (`entity_id`) ON DELETE CASCADE ON U)' in /home/**********/domains/***********nna.nl/public_html/lib/Zend/Db/Statement/Pdo.php:228
Stack trace:
#0 /home/**********/domains/***********nna.nl/public_html/lib/Zend/Db/Statement/Pdo.php(228): PDOStatement->execute(Array)
#1 /home/**********/domains/***********nna.nl/public_html/lib/Varien/Db/Statement/Pdo/Mysql.php(110): Zend_Db_Statement_Pdo->_execute(Array)
#2 /home/**********/domains/***********nna.nl/public_html/lib/Zend/Db/Statement.php(300): Varien_Db_Statement_Pdo_Mysql->_execute(Array)
#3 /home/**********/domains/***********nna.nl/public_html/lib/Zend/Db/Adapter/Abstract.php(479): Zend_Db_Statement->execute(Array)
#4 /home/**********/domains/***********nna.nl/public_html/lib/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('ALTER TABLE `ca...', Array)
#5 /home/**********/domains/***********nna.nl/public_html/lib/Varien/Db/Adapter/Pdo/Mysql.php(419): Zend_Db_Adapter_Pdo_Abstract->query('ALTER TABLE `ca...', Array)
#6 /home/**********/domains/***********nna.nl/public_html/lib/Varien/Db/Adapter/Pdo/Mysql.php(340): Varien_Db_Adapter_Pdo_Mysql->query('ALTER TABLE `ca...')
#7 /home/**********/domains/***********nna.nl/public_html/lib/Varien/Db/Adapter/Pdo/Mysql.php(2569): Varien_Db_Adapter_Pdo_Mysql->raw_query('ALTER TABLE `ca...')
#8 /home/**********/domains/***********nna.nl/public_html/app/code/core/Mage/Catalog/Model/Resource/Product/Flat/Indexer.php(816): Varien_Db_Adapter_Pdo_Mysql->addForeignKey('FK_CAT_PRD_FLAT...', 'catalog_product...', 'entity_id', 'catalog_product...', 'entity_id', 'CASCADE', 'CASCADE')
#9 /home/**********/domains/***********nna.nl/public_html/app/code/core/Mage/Catalog/Model/Resource/Product/Flat/Indexer.php(1390): Mage_Catalog_Model_Resource_Product_Flat_Indexer->prepareFlatTable(1)
#10 /home/**********/domains/***********nna.nl/public_html/app/code/core/Mage/Catalog/Model/Product/Flat/Indexer.php(296): Mage_Catalog_Model_Resource_Product_Flat_Indexer->reindexAll()
#11 /home/**********/domains/***********nna.nl/public_html/app/code/core/Mage/Catalog/Model/Product/Indexer/Flat.php(336): Mage_Catalog_Model_Product_Flat_Indexer->reindexAll()
#12 /home/**********/domains/***********nna.nl/public_html/app/code/core/Mage/Index/Model/Process.php(209): Mage_Catalog_Model_Product_Indexer_Flat->reindexAll()
#13 /home/**********/domains/***********nna.nl/public_html/app/code/core/Mage/Index/Model/Process.php(255): Mage_Index_Model_Process->reindexAll()
#14 /home/**********/domains/***********nna.nl/public_html/shell/indexer.php(160): Mage_Index_Model_Process->reindexEverything()
#15 /home/**********/domains/***********nna.nl/public_html/shell/indexer.php(200): Mage_Shell_Compiler->run()
#16 {main}






magento-1.7 indexing sql reindex






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 26 mins ago









Teja Bhagavan Kollepara

3,01241949




3,01241949










asked Jan 8 '15 at 9:56









xviloxvilo

1519




1519













  • Check my answer on this link magento.stackexchange.com/questions/105393/… Hope this will help you

    – Asish Hira
    Mar 14 '16 at 7:27



















  • Check my answer on this link magento.stackexchange.com/questions/105393/… Hope this will help you

    – Asish Hira
    Mar 14 '16 at 7:27

















Check my answer on this link magento.stackexchange.com/questions/105393/… Hope this will help you

– Asish Hira
Mar 14 '16 at 7:27





Check my answer on this link magento.stackexchange.com/questions/105393/… Hope this will help you

– Asish Hira
Mar 14 '16 at 7:27










2 Answers
2






active

oldest

votes


















7














it seams that you have zombie data in the flat table for store with id 1.

The prepareFlatTable method is trying to add a Foreign Key to the catalog_product_entity table and that fails.

Most probably because you already have in the catalog_product_flat_store_1 table a product id that is not in the catalog_product_entity table.



First backup your database (or at least catalog_product_flat_store_1 table), then truncate the table catalog_product_flat_store_1.



Or you can disable the usage of the flat catalog, remove the tables catalog_product_flat_store_*, re run the indexing then enable the usage of flat tables again.






share|improve this answer
























  • i only have a table called catalog_product_flat_1, could that be the same?

    – xvilo
    Jan 8 '15 at 12:59











  • yes. I assume you have only one store view in your instance. the 1 at the end is the store view id. Magento creates one flat table for each store view.

    – Marius
    Jan 8 '15 at 13:46











  • Yes, Thank you for this answer, couldn't find the right one on the interwebs

    – xvilo
    Jan 8 '15 at 16:01



















-1














I have 4 languages so i truncated 4 tables.
catalog_product_flat_1, 2, 3, 4





share|improve this answer


























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "479"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f51536%2fmagento-indexing-is-failing-sqlstate23000-integrity-constraint-violation%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    7














    it seams that you have zombie data in the flat table for store with id 1.

    The prepareFlatTable method is trying to add a Foreign Key to the catalog_product_entity table and that fails.

    Most probably because you already have in the catalog_product_flat_store_1 table a product id that is not in the catalog_product_entity table.



    First backup your database (or at least catalog_product_flat_store_1 table), then truncate the table catalog_product_flat_store_1.



    Or you can disable the usage of the flat catalog, remove the tables catalog_product_flat_store_*, re run the indexing then enable the usage of flat tables again.






    share|improve this answer
























    • i only have a table called catalog_product_flat_1, could that be the same?

      – xvilo
      Jan 8 '15 at 12:59











    • yes. I assume you have only one store view in your instance. the 1 at the end is the store view id. Magento creates one flat table for each store view.

      – Marius
      Jan 8 '15 at 13:46











    • Yes, Thank you for this answer, couldn't find the right one on the interwebs

      – xvilo
      Jan 8 '15 at 16:01
















    7














    it seams that you have zombie data in the flat table for store with id 1.

    The prepareFlatTable method is trying to add a Foreign Key to the catalog_product_entity table and that fails.

    Most probably because you already have in the catalog_product_flat_store_1 table a product id that is not in the catalog_product_entity table.



    First backup your database (or at least catalog_product_flat_store_1 table), then truncate the table catalog_product_flat_store_1.



    Or you can disable the usage of the flat catalog, remove the tables catalog_product_flat_store_*, re run the indexing then enable the usage of flat tables again.






    share|improve this answer
























    • i only have a table called catalog_product_flat_1, could that be the same?

      – xvilo
      Jan 8 '15 at 12:59











    • yes. I assume you have only one store view in your instance. the 1 at the end is the store view id. Magento creates one flat table for each store view.

      – Marius
      Jan 8 '15 at 13:46











    • Yes, Thank you for this answer, couldn't find the right one on the interwebs

      – xvilo
      Jan 8 '15 at 16:01














    7












    7








    7







    it seams that you have zombie data in the flat table for store with id 1.

    The prepareFlatTable method is trying to add a Foreign Key to the catalog_product_entity table and that fails.

    Most probably because you already have in the catalog_product_flat_store_1 table a product id that is not in the catalog_product_entity table.



    First backup your database (or at least catalog_product_flat_store_1 table), then truncate the table catalog_product_flat_store_1.



    Or you can disable the usage of the flat catalog, remove the tables catalog_product_flat_store_*, re run the indexing then enable the usage of flat tables again.






    share|improve this answer













    it seams that you have zombie data in the flat table for store with id 1.

    The prepareFlatTable method is trying to add a Foreign Key to the catalog_product_entity table and that fails.

    Most probably because you already have in the catalog_product_flat_store_1 table a product id that is not in the catalog_product_entity table.



    First backup your database (or at least catalog_product_flat_store_1 table), then truncate the table catalog_product_flat_store_1.



    Or you can disable the usage of the flat catalog, remove the tables catalog_product_flat_store_*, re run the indexing then enable the usage of flat tables again.







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Jan 8 '15 at 10:01









    MariusMarius

    167k28319686




    167k28319686













    • i only have a table called catalog_product_flat_1, could that be the same?

      – xvilo
      Jan 8 '15 at 12:59











    • yes. I assume you have only one store view in your instance. the 1 at the end is the store view id. Magento creates one flat table for each store view.

      – Marius
      Jan 8 '15 at 13:46











    • Yes, Thank you for this answer, couldn't find the right one on the interwebs

      – xvilo
      Jan 8 '15 at 16:01



















    • i only have a table called catalog_product_flat_1, could that be the same?

      – xvilo
      Jan 8 '15 at 12:59











    • yes. I assume you have only one store view in your instance. the 1 at the end is the store view id. Magento creates one flat table for each store view.

      – Marius
      Jan 8 '15 at 13:46











    • Yes, Thank you for this answer, couldn't find the right one on the interwebs

      – xvilo
      Jan 8 '15 at 16:01

















    i only have a table called catalog_product_flat_1, could that be the same?

    – xvilo
    Jan 8 '15 at 12:59





    i only have a table called catalog_product_flat_1, could that be the same?

    – xvilo
    Jan 8 '15 at 12:59













    yes. I assume you have only one store view in your instance. the 1 at the end is the store view id. Magento creates one flat table for each store view.

    – Marius
    Jan 8 '15 at 13:46





    yes. I assume you have only one store view in your instance. the 1 at the end is the store view id. Magento creates one flat table for each store view.

    – Marius
    Jan 8 '15 at 13:46













    Yes, Thank you for this answer, couldn't find the right one on the interwebs

    – xvilo
    Jan 8 '15 at 16:01





    Yes, Thank you for this answer, couldn't find the right one on the interwebs

    – xvilo
    Jan 8 '15 at 16:01













    -1














    I have 4 languages so i truncated 4 tables.
    catalog_product_flat_1, 2, 3, 4





    share|improve this answer






























      -1














      I have 4 languages so i truncated 4 tables.
      catalog_product_flat_1, 2, 3, 4





      share|improve this answer




























        -1












        -1








        -1







        I have 4 languages so i truncated 4 tables.
        catalog_product_flat_1, 2, 3, 4





        share|improve this answer















        I have 4 languages so i truncated 4 tables.
        catalog_product_flat_1, 2, 3, 4






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Dec 31 '18 at 4:23









        Teja Bhagavan Kollepara

        3,01241949




        3,01241949










        answered Dec 31 '18 at 2:35









        hakanhakan

        44




        44






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Magento Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f51536%2fmagento-indexing-is-failing-sqlstate23000-integrity-constraint-violation%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            “%fieldName is a required field.”, in Magento2 REST API Call for GET Method Type The Next...

            How to change City field to a dropdown in Checkout step Magento 2Magento 2 : How to change UI field(s)...

            夢乃愛華...