I am facing a error while adding a new product or category from back-end. The error is as follows:

SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'entity_id' cannot be null, query was: INSERT INTO `catalog_product_entity` (`row_id`, `entity_id`, `created_in`, `updated_in`, `attribute_set_id`, `type_id`, `sku`, `has_options`, `required_options`, `created_at`, `updated_at`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)

1 Answer 1


This is an Known issue for Magento 2.x, we faced same issue several time for our project on Magento 2.2.x

Solution worked for me is reindex: just try below steps, if it doesn't work then let me know output while executing these commands.

php bin/magento s:up
php bin/magento indexer:reindex
php bin/magento c:c
php bin/magento c:f

  • Also try disabling flat structure for category and Products
    – Om Prakash
    Commented Sep 9, 2019 at 11:11
  • thanks for the reply but this solution did not work for me. During setup upgrade, I got a error which is as follows. SQLSTATE[42S22]: Column not found: 1054 Unknown column 'entity_id' in 'NEW', query was: CREATE TRIGGER trg_catalog_product_entity_int_after_insert AFTER INSERT ON catalog_product_entity_int FOR EACH ROW Commented Sep 9, 2019 at 11:23
  • Try: php bin/magento indexer:set-mode realtime once issue is fixed then run this command: php bin/magento indexer:set-mode schedule php bin/magento indexer:reindex
    – Om Prakash
    Commented Sep 9, 2019 at 16:53
  • if above solution doesn't work then try disabling all third party extensions and check
    – Om Prakash
    Commented Sep 9, 2019 at 16:55
  • When I tried to chnage the indexer mode then I faced the following error: Unknown column 'entity_id' in 'NEW', query was: CREATE TRIGGER trg_catalog_product_entity_datetime_after_insert AFTER INSERT ON catalog_product_entity_datetime FOR EACH ROW Commented Sep 10, 2019 at 5:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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