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

Increase performance creating Mandelbrot set in python

What is the difference between "behavior" and "behaviour"?

How to make a software documentation "officially" citable?

India just shot down a satellite from the ground. At what altitude range is the resulting debris field?

Was a professor correct to chastise me for writing "Prof. X" rather than "Professor X"?

Whats the best way to handle refactoring a big file?

How do we know the LHC results are robust?

How can I open an app using Terminal?

Apart from "berlinern", do any other German dialects have a corresponding verb?

Why were Madagascar and New Zealand discovered so late?

Is it safe to use c_str() on a temporary string?

How do I go from 300 unfinished/half written blog posts, to published posts?

Why didn't Khan get resurrected in the Genesis Explosion?

Customer Requests (Sometimes) Drive Me Bonkers!

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

Why do professional authors make "consistency" mistakes? And how to avoid them?

If the heap is initialized for security, then why is the stack uninitialized?

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

Only print output after finding pattern

How to write the block matrix in LaTex?

How to write papers efficiently when English isn't my first language?

What makes a siege story/plot interesting?

Why does standard notation not preserve intervals (visually)

What do "high sea" and "carry" mean in this sentence?



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 34 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

            Magento 2 duplicate PHPSESSID cookie when using session_start() in custom php scriptMagento 2: User cant logged in into to account page, no error showing!Magento duplicate on subdomainGrabbing storeview from cookie (after using language selector)How do I run php custom script on magento2Magento 2: Include PHP script in headerSession lock after using Cm_RedisSessionscript php to update stockMagento set cookie popupMagento 2 session id cookie - where to find it?How to import Configurable product from csv with custom attributes using php scriptMagento 2 run custom PHP script

            Can not update quote_id field of “quote_item” table magento 2Magento 2.1 - We can't remove the item. (Shopping Cart doesnt allow us to remove items before becomes empty)Add value for custom quote item attribute using REST apiREST API endpoint v1/carts/cartId/items always returns error messageCorrect way to save entries to databaseHow to remove all associated quote objects of a customer completelyMagento 2 - Save value from custom input field to quote_itemGet quote_item data using quote id and product id filter in Magento 2How to set additional data to quote_item table from controller in Magento 2?What is the purpose of additional_data column in quote_item table in magento2Set Custom Price to Quote item magento2 from controller

            How to solve knockout JS error in Magento 2 Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?(Magento2) knockout.js:3012 Uncaught ReferenceError: Unable to process bindingUnable to process binding Knockout.js magento 2Cannot read property `scopeLabel` of undefined on Product Detail PageCan't get Customer Data on frontend in Magento 2Magento2 Order Summary - unable to process bindingKO templates are not loading in Magento 2.1 applicationgetting knockout js error magento 2Product grid not load -— Unable to process binding Knockout.js magento 2Product form not loaded in magento2Uncaught ReferenceError: Unable to process binding “if: function()return (isShowLegend()) ” magento 2