If you wish to delete all products from all the stores:
truncate table catalog_product_entity;
If only for one store (2 is store_id you wish to clean):
delete from catalog_product_store where store_id=2; delete from catalog_product_entity_datetime where store_id=2; delete from catalog_product_entity_decimal where store_id=2; delete from catalog_product_entity_int where store_id=2; delete from catalog_product_entity_varchar where store_id=2; delete from catalog_product_entity_text where store_id=2; delete from catalog_product_entity_gallery where store_id=2; delete from catalog_product_entity_tierprice where store_id=2;
Moshe,
I’ve been running into a lot of problems importing products. Then I’m left with junk in the product tables. I tried cleaning out the catalog_product_entity like you said, but now I’m getting this error on import.
This error:
# SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry ‘4-1’ for key 2
Are there more tables I need to clear out to get rid of all previous product import attempts or will this clear out all the tables that are linked to it?
Thanks!
Shay’s SQL is the most complete, but I’ve found additional tables that are also required to be deleted. My problem is that I know there are STILL MORE we are missing since I am still getting errors. Please add to this if you can.
ALTER TABLE `catalog_product_website` AUTO_INCREMENT =1;
ALTER TABLE `catalog_category_product` AUTO_INCREMENT =1;
ALTER TABLE `catalog_product_entity` AUTO_INCREMENT =1;
ALTER TABLE `catalog_product_entity_datetime` AUTO_INCREMENT =1;
ALTER TABLE `catalog_product_entity_decimal` AUTO_INCREMENT =1;
ALTER TABLE `catalog_product_entity_gallery` AUTO_INCREMENT =1;
ALTER TABLE `catalog_product_entity_int` AUTO_INCREMENT =1;
ALTER TABLE `catalog_product_entity_media_gallery` AUTO_INCREMENT =1;
ALTER TABLE `catalog_product_entity_media_gallery_value` AUTO_INCREMENT =1;
ALTER TABLE `catalog_product_entity_text` AUTO_INCREMENT =1;
ALTER TABLE `catalog_product_entity_tier_price` AUTO_INCREMENT =1;
ALTER TABLE `catalog_product_entity_varchar` AUTO_INCREMENT =1;
DELETE FROM `core_url_rewrite`
WHERE `id_path` LIKE ‘PERCENT SIGN product PERCENT SIGN’
But still getting
SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry ‘1-1’ for key 2
on trying to import a product that was previously deleted.
DELETE FROM `core_url_rewrite`
WHERE `id_path` LIKE ‘PERCENT SIGN product PERCENT SIGN’
But still getting
SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry ‘1-1’ for key 2
on trying to import a product that was previously deleted.
I have figured out a way of getting rid of the constraint violation error… using the above and a bit of hunting and trial and error I have got the following queries to get rid of the error:
EDIT: ... I think this causes an error on the products page (ie kills it!)… so it is a query or two, too many! :(
DELETED - see below
I am only in my second week of magento, so use at own risk!
# I think this is Where configurable products are stored TRUNCATE catalog_product_super_attribute; TRUNCATE catalog_product_super_attribute_label; TRUNCATE catalog_product_super_attribute_pricing; TRUNCATE catalog_product_super_link; #
# assign the products to a website(s) TRUNCATE catalog_product_website;