0

After migration everything is working except category issue. Not able to add or update category, getting this error in exception.log

[2018-02-10 20:18:00] main.CRITICAL: exception 'PDOException' with message 'SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (newdb.magento_catalog_category_entity_varchar, CONSTRAINT CATALOG_CATEGORY_ENTITY_VARCHAR_STORE_ID_STORE_STORE_ID FOREIGN KEY (store_id) REFERENCES magento_store (store_id) ON D)' in /home/domain/public_html/vendor/magento/zendframework1/library/Zend/Db/Statement/Pdo.php:228 Stack trace: 0/home/domain/public_html/vendor/magento/zendframework1/library/Zend/Db/Statement/Pdo.php(228): PDOStatement->execute(Array)

1 /home/domain/public_html/vendor/magento/framework/DB/Statement/Pdo/Mysql.php(95): Zend_Db_Statement_Pdo->_execute(Array)

2 home/domain/public_html/vendor/magento/zendframework1/library/Zend/Db/Statement.php(303): Magento\Framework\DB\Statement\Pdo\Mysql->_execute(Array)

3 /home/domain/public_html/vendor/magento/zendframework1/library/Zend/Db/Adapter/Abstract.php(480): Zend_Db_Statement->execute(Array)

4 /home/domain/public_html/vendor/magento/zendframework1/library/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('INSERT INTO `mg...', Array)

5 /home/domain/public_html/vendor/magento/framework/DB/Adapter/Pdo/Mysql.php(452): Zend_Db_Adapter_Pdo_Abstract->query('INSERT INTO `mg...', Array)

6 /home/domain/public_html/vendor/magento/framework/DB/Adapter/Pdo/Mysql.php(507): Magento\Framework\DB\Adapter\Pdo\Mysql->_query('INSERT INTO `mg...', Array)

7 /home/domain/public_html/vendor/magento/framework/DB/Adapter/Pdo/Mysql.php(1851): Magento\Framework\DB\Adapter\Pdo\Mysql->query('INSERT INTO `mg...', Array)

8 /home/domain/public_html/vendor/magento/module-eav/Model/ResourceModel/AttributePersistor.php(165): Magento\Framework\DB\Adapter\Pdo\Mysql->insertOnDuplicate('magento_catalog_ca...', Array)

9 /home/domain/public_html/vendor/magento/module-eav/Model/ResourceModel/AttributePersistor.php(219): Magento\Eav\Model\ResourceModel\AttributePersistor->processInserts('Magento\Catalog...', Array)

10 /home/domain/public_html/vendor/magento/module-eav/Model/ResourceModel/CreateHandler.php(115): Magento\Eav\Model\ResourceModel\AttributePersistor->flush('Magento\Catalog...', Array)

11 /home/domain/public_html/vendor/magento/framework/EntityManager/Operation/Create/CreateAttributes.php(59): Magento\Eav\Model\ResourceModel\CreateHandler->execute('Magento\Catalog...', Array, Array)

12 /home/domain/public_html/vendor/magento/framework/EntityManager/Operation/Create.php(106): Magento\Framework\EntityManager\Operation\Create\CreateAttributes->execute(Object(Plazathemes\Override\Model\Category\Interceptor), Array)

13 /home/domain/public_html/vendor/magento/framework/EntityManager/EntityManager.php(87): Magento\Framework\EntityManager\Operation\Create->execute(Object(Plazathemes\Override\Model\Category\Interceptor), Array)

14 /home/domain/public_html/vendor/magento/module-catalog/Model/ResourceModel/Category.php(1025): Magento\Framework\EntityManager\EntityManager->save(Object(Plazathemes\Override\Model\Category\Interceptor))

15 /home/domain/public_html/vendor/magento/framework/Interception/Interceptor.php(74): Magento\Catalog\Model\ResourceModel\Category->save(Object(Plazathemes\Override\Model\Category\Interceptor))

16 /home/domain/public_html/vendor/magento/framework/Interception/Chain/Chain.php(70): Magento\Catalog\Model\ResourceModel\Category\Interceptor->___callParent('save', Array)

17 /home/domain/public_html/vendor/magento/framework/Interception/Chain/Chain.php(63): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\Catalog...', 'save', Object(Magento\Catalog\Model\ResourceModel\Category\Interceptor), Array, 'clean_cache')

18 /home/domain/public_html/vendor/magento/framework/App/Cache/FlushCacheByTags.php(60): Magento\Framework\Interception\Chain\Chain->Magento\Framework\Interception\Chain{closure}(Object(Plazathemes\Override\Model\Category\Interceptor))

19 /home/domain/public_html/vendor/magento/framework/Interception/Chain/Chain.php(67): Magento\Framework\App\Cache\FlushCacheByTags->aroundSave(Object(Magento\Catalog\Model\ResourceModel\Category\Interceptor), Object(Closure), Object(Plazathemes\Override\Model\Category\Interceptor))

20 /home/domain/public_html/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\Catalog...', 'save', Object(Magento\Catalog\Model\ResourceModel\Category\Interceptor), Array, 'catalogsearchFu...')

21 /home/domain/public_html/vendor/magento/module-catalog-search/Model/Indexer/Fulltext/Plugin/Category.php(43): Magento\Catalog\Model\ResourceModel\Category\Interceptor->Magento\Framework\Interception{closure}(Object(Plazathemes\Override\Model\Category\Interceptor))

22 /home/domain/public_html/vendor/magento/module-catalog-search/Model/Indexer/Fulltext/Plugin/Category.php(29): Magento\CatalogSearch\Model\Indexer\Fulltext\Plugin\Category->addCommitCallback(Object(Magento\Catalog\Model\ResourceModel\Category\Interceptor), Object(Closure), Object(Plazathemes\Override\Model\Category\Interceptor))

23 /home/domain/public_html/vendor/magento/framework/Interception/Interceptor.php(142): Magento\CatalogSearch\Model\Indexer\Fulltext\Plugin\Category->aroundSave(Object(Magento\Catalog\Model\ResourceModel\Category\Interceptor), Object(Closure), Object(Plazathemes\Override\Model\Category\Interceptor))

24 /home/domain/public_html/var/generation/Magento/Catalog/Model/ResourceModel/Category/Interceptor.php(364): Magento\Catalog\Model\ResourceModel\Category\Interceptor->___callPlugins('save', Array, Array)

25 /home/domain/public_html/vendor/magento/framework/Model/AbstractModel.php(631): Magento\Catalog\Model\ResourceModel\Category\Interceptor->save(Object(Plazathemes\Override\Model\Category\Interceptor))

26 /home/domain/public_html/vendor/magento/framework/Interception/Interceptor.php(146): Magento\Framework\Model\AbstractModel->save()

27 /home/domain/public_html/var/generation/Plazathemes/Override/Model/Category/Interceptor.php(1547): Plazathemes\Override\Model\Category\Interceptor->___callPlugins('save', Array, Array)

28 /home/domain/public_html/vendor/magento/module-catalog/Controller/Adminhtml/Category/Save.php(203): Plazathemes\Override\Model\Category\Interceptor->save()

29 /home/domain/public_html/var/generation/Plazathemes/Override/Controller/Adminhtml/Category/Save/Interceptor.php(37): Magento\Catalog\Controller\Adminhtml\Category\Save->execute()

30 /home/domain/public_html/vendor/magento/framework/App/Action/Action.php(102): Plazathemes\Override\Controller\Adminhtml\Category\Save\Interceptor->execute()

31 /home/domain/public_html/vendor/magento/module-backend/App/AbstractAction.php(226): Magento\Framework\App\Action\Action->dispatch(Object(Magento\Framework\App\Request\Http))

32 /home/domain/public_html/vendor/magento/framework/Interception/Interceptor.php(74): Magento\Backend\App\AbstractAction->dispatch(Object(Magento\Framework\App\Request\Http))

33 /home/domain/public_html/vendor/magento/framework/Interception/Chain/Chain.php(70): Plazathemes\Override\Controller\Adminhtml\Category\Save\Interceptor->___callParent('dispatch', Array)

34 /home/domain/public_html/vendor/magento/framework/Interception/Chain/Chain.php(63): Magento\Framework\Interception\Chain\Chain->invokeNext('Plazathemes\Ove...', 'dispatch', Object(Plazathemes\Override\Controller\Adminhtml\Category\Save\Interceptor), Array, 'adminAuthentica...')

35 /home/domain/public_html/vendor/magento/module-backend/App/Action/Plugin/Authentication.php(143): Magento\Framework\Interception\Chain\Chain->Magento\Framework\Interception\Chain{closure}(Object(Magento\Framework\App\Request\Http))

36 /home/domain/public_html/vendor/magento/framework/Interception/Chain/Chain.php(67): Magento\Backend\App\Action\Plugin\Authentication->aroundDispatch(Object(Plazathemes\Override\Controller\Adminhtml\Category\Save\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))

37 /home/domain/public_html/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\Interception\Chain\Chain->invokeNext('Plazathemes\Ove...', 'dispatch', Object(Plazathemes\Override\Controller\Adminhtml\Category\Save\Interceptor), Array, 'adminMassaction...')

38 /home/domain/public_html/vendor/magento/module-backend/App/Action/Plugin/MassactionKey.php(33): Plazathemes\Override\Controller\Adminhtml\Category\Save\Interceptor->Magento\Framework\Interception{closure}(Object(Magento\Framework\App\Request\Http))

39 /home/domain/public_html/vendor/magento/framework/Interception/Interceptor.php(142): Magento\Backend\App\Action\Plugin\MassactionKey->aroundDispatch(Object(Plazathemes\Override\Controller\Adminhtml\Category\Save\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))

40 /home/domain/public_html/var/generation/Plazathemes/Override/Controller/Adminhtml/Category/Save/Interceptor.php(65): Plazathemes\Override\Controller\Adminhtml\Category\Save\Interceptor->___callPlugins('dispatch', Array, Array)

41 /home/domain/public_html/vendor/magento/framework/App/FrontController.php(55): Plazathemes\Override\Controller\Adminhtml\Category\Save\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))

42 /home/domain/public_html/vendor/magento/framework/Interception/Interceptor.php(74): Magento\Framework\App\FrontController->dispatch(Object(Magento\Framework\App\Request\Http))

43 /home/domain/public_html/vendor/magento/framework/Interception/Chain/Chain.php(70): Magento\Framework\App\FrontController\Interceptor->___callParent('dispatch', Array)

44 /home/domain/public_html/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\Framewo...', 'dispatch', Object(Magento\Framework\App\FrontController\Interceptor), Array, 'install')

45 /home/domain/public_html/vendor/magento/framework/Module/Plugin/DbStatusValidator.php(69): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception{closure}(Object(Magento\Framework\App\Request\Http))

46 /home/domain/public_html/vendor/magento/framework/Interception/Interceptor.php(142): Magento\Framework\Module\Plugin\DbStatusValidator->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))

47 /home/domain/public_html/var/generation/Magento/Framework/App/FrontController/Interceptor.php(26): Magento\Framework\App\FrontController\Interceptor->___callPlugins('dispatch', Array, Array)

48 /home/domain/public_html/vendor/magento/framework/App/Http.php(135): Magento\Framework\App\FrontController\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))

49 /home/domain/public_html/vendor/magento/framework/App/Bootstrap.php(258): Magento\Framework\App\Http->launch()

50 /home/domain/public_html/index.php(39): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http))

51 {main}

0

Problem with foreigh key between tables magento_catalog_category_entity_varchar and magento_store.

Please check what kind of values you have for column store_id in magento_catalog_category_entity_varchar and if this value is existing in magento_store.

  • Both table have similar values, column with same name, here is the screenshot. magento_store = prntscr.com/id6wro magento_catalog_category_entity_varchar = prntscr.com/id6wmj – Harish Kumar Feb 11 '18 at 14:41
  • Looks like some problem with migration in that case. Did you tried to upgrade to 2.1.11 (latest stable version of 2.1 release)? – rafal-kos Feb 11 '18 at 19:29
  • thanks for your efforts and response friend, i figured it out, actually table type was changed from InnoDB somehow, had reverted and all seems fine now. – Harish Kumar Feb 12 '18 at 20:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.