cancel
Showing results for 
Search instead for 
Did you mean: 

Error inserting products after deleting store view in magento 2.4

Error inserting products after deleting store view in magento 2.4

I installed a themeforest layout using the demo package. All worked fine. This demo has some store views for example. I deleted all store fronts that I will not need and the frontend worked fine!

The problem is: When I try to insert a new product I'm receiving this error:

 

SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`loja_magento`.`catalog_product_website`, CONSTRAINT `CATALOG_PRODUCT_WEBSITE_WEBSITE_ID_STORE_WEBSITE_WEBSITE_ID` FOREIGN KEY (`website_id`) REFERENCES `store_website` (`website_id`) ON DELET), query was: INSERT INTO `catalog_product_website` (`product_id`,`website_id`) VALUES (?, ?)

I have no idea how to fix it. Someone can help me?

3 REPLIES 3

Re: Error inserting products after deleting store view in magento 2.4

Have you found a solution for your error?  I've having the same issue.  I switched from a multistore setup back to a single store.  I can duplicate a product to add a new product but I can't add from a blank start.

 

Rich

Re: Error inserting products after deleting store view in magento 2.4

Hey guys any luck solving this one? experiencing the same issue now.

Re: Error inserting products after deleting store view in magento 2.4

No.. I dont found a solution, but i think its a magento bug.
You don't are able to delede ID 0. For example, you can have 10 stores, but if you delete storefront id 0 this probleem will occurs.
Solution: Dont revome ID 0, rename it and all things still work fine

 

https://github.com/magento/magento2/issues/30503