Saturday, December 12, 2015

Solve 'integrity constraint violation:1048' Error in Magento


If you use Magento or have an own Magento store than you fetch ‘integrity constraint violation’ in some cases. This error, mostly displays when add products by CSV file and save or create products. This error displays on admin panel when any products trigger event fire.
This error is not only in Magento it’s also display many other CMS like Drupal. This error because of foreign key relation on database. In Magento many tables connected each other with foreign key and data getting according to that relation and when there is some mistake in that relation data than this type of error display.
When you import product from CSV than display ‘value’,’ attribute_id’,‘entity_id’ cannot be null or sometimes when save product data by programmatically, add from admin panel. For that here is below display simple solution.
  • If you add products from CSV than must check all data is there any null value which is required in your magneto store than fill that value.
  • If you add a product programmatically than check all products required data which is set or not.
  • When you create product from admin panel and display below error then check the database first. Check table display in error with column value and check is there any NULL or missing value? If yes then fills according to other. Example: - integrity constraint violation: 1048 column `child_id` can’t be null, query was: INSERT INTO `catalog_product_relation` (`parent_id`,`child_id`) VALUES (?, ?)
    Here below error check column `child_id` on `catalog_product_relation ` and fill NULL value. 
After complete below process clear all caches and re indexing all data and check again you will be solve this error.

No comments :

Post a Comment