Magento Forum

   
Possible to delete all products and reset product id’s? 
 
doughboy
Member
 
Total Posts:  55
Joined:  2010-03-29
 

Christian Munch,
thanks!!  that worked perfect for me.  I am running 1.4.1.1

 
Magento Community Magento Community
Magento Community
Magento Community
 
junomedia
Sr. Member
 
Avatar
Total Posts:  142
Joined:  2008-09-10
Nottingham, England
 

Thanks, works perfect for me too on mage 1.4.0.1

Andy.

 
Magento Community Magento Community
Magento Community
Magento Community
 
italus
Jr. Member
 
Total Posts:  4
Joined:  2009-08-05
 

Hello
an I run the script on magento 1.3.2.4 ?
Please help

 
Magento Community Magento Community
Magento Community
Magento Community
 
kachuru
Jr. Member
 
Total Posts:  4
Joined:  2010-11-26
 

It’s also possible to execute arbitrary SQL via Magento scripts like so:

$conn   Mage::getModel('core/resource')->getConnection();
$tables = array('catalog_product_entity', ...);

foreach (
$tables as $table{
    $conn
->query("TRUNCATE TABLE {$table}");
}

Not necessarily the absolute ‘correct’ way to do things in Magento, but better that deleting each individual product one-by-one if you simply need to tear down the existing data and reimport it.

 
Magento Community Magento Community
Magento Community
Magento Community
 
realsmack
Jr. Member
 
Total Posts:  3
Joined:  2010-02-11
 

I found I also had to truncate the catalogsearch_fulltext table, otherwise I got duplicate key errors. I also decided to clear out some other cruft, as all the information was pre-launch:

// required
TRUNCATE TABLE `catalogsearch_fulltext`;

//looks like these also had lots of cruft
TRUNCATE TABLE `catalogindex_price`;
TRUNCATE TABLE `catalogindex_eav`;

// may as well also clear out log info
TRUNCATE TABLE `log_url`;
TRUNCATE TABLE `log_url_info`;
TRUNCATE TABLE `log_visitor`;
TRUNCATE TABLE `log_visitor_info`;

thanks for the tip - worked a charm.

 
Magento Community Magento Community
Magento Community
Magento Community
 
shmk
Sr. Member
 
Total Posts:  296
Joined:  2009-10-28
 

Anyone has a SECURE solution to use on a online (not in developing, so I can’t brake anyhting in the system rasberry) Magento 1.4.2.0?

 
Magento Community Magento Community
Magento Community
Magento Community
 
RoelAlblas
Jr. Member
 
Total Posts:  18
Joined:  2010-08-07
 

[/code][quote author="Christian Münch" date="1266678077"]
[code]
SET FOREIGN_KEY_CHECKS 
0;
TRUNCATE TABLE `catalog_product_bundle_option`;
TRUNCATE TABLE `catalog_product_bundle_option_value`;
TRUNCATE TABLE `catalog_product_bundle_selection`;
TRUNCATE TABLE `catalog_product_entity_datetime`;
TRUNCATE TABLE `catalog_product_entity_decimal`;
TRUNCATE TABLE `catalog_product_entity_gallery`;
TRUNCATE TABLE `catalog_product_entity_int`;
TRUNCATE TABLE `catalog_product_entity_media_gallery`;
TRUNCATE TABLE `catalog_product_entity_media_gallery_value`;
TRUNCATE TABLE `catalog_product_entity_text`;
TRUNCATE TABLE `catalog_product_entity_tier_price`;
TRUNCATE TABLE `catalog_product_entity_varchar`;
TRUNCATE TABLE `catalog_product_link`;
TRUNCATE TABLE `catalog_product_link_attribute`;
TRUNCATE TABLE `catalog_product_link_attribute_decimal`;
TRUNCATE TABLE `catalog_product_link_attribute_int`;
TRUNCATE TABLE `catalog_product_link_attribute_varchar`;
TRUNCATE TABLE `catalog_product_link_type`;
TRUNCATE TABLE `catalog_product_option`;
TRUNCATE TABLE `catalog_product_option_price`;
TRUNCATE TABLE `catalog_product_option_title`;
TRUNCATE TABLE `catalog_product_option_type_price`;
TRUNCATE TABLE `catalog_product_option_type_title`;
TRUNCATE TABLE `catalog_product_option_type_value`;
TRUNCATE TABLE `catalog_product_super_attribute_label`;
TRUNCATE TABLE `catalog_product_super_attribute_pricing`;
TRUNCATE TABLE `catalog_product_super_attribute`;
TRUNCATE TABLE `catalog_product_super_link`;
TRUNCATE TABLE `catalog_product_enabled_index`;
TRUNCATE TABLE `catalog_product_website`;
TRUNCATE TABLE `catalog_category_product_index`;
TRUNCATE TABLE `catalog_category_product`;
TRUNCATE TABLE `cataloginventory_stock_item`;
TRUNCATE TABLE `cataloginventory_stock_status`;
TRUNCATE TABLE `cataloginventory_stock`;
INSERT  INTO `catalog_product_link_type`(`link_type_id`,`code`) VALUES (1,'relation'),(2,'bundle'),(3,'super'),(4,'up_sell'),(5,'cross_sell');
INSERT  INTO `catalog_product_link_attribute`(`product_link_attribute_id`,`link_type_id`,`product_link_attribute_code`,`data_type`) VALUES (1,2,'qty','decimal'),(2,1,'position','int'),(3,4,'position','int'),(4,5,'position','int'),(6,1,'qty','decimal'),(7,3,'position','int'),(8,3,'qty','decimal');
INSERT  INTO `cataloginventory_stock`(`stock_id`,`stock_name`) VALUES (1,'Default');
TRUNCATE TABLE `catalog_product_entity`;
SET FOREIGN_KEY_CHECKS 1;

I can confirm that this works on version 1.4.2.

 
Magento Community Magento Community
Magento Community
Magento Community
 
louisliu
Jr. Member
 
Total Posts:  7
Joined:  2009-06-09
 

That’s great, i’m looking for that. I’ll test that.

 
Magento Community Magento Community
Magento Community
Magento Community
 
skeptical
Member
 
Total Posts:  34
Joined:  2009-03-02
 

I’m running 1.4.1 and using the “select all” and “delete” function. However that doesn’t seem to work as I keep getting this error from Nginx:

504 Gateway Time-out

Even when I’m only selecting 100 products it’s doing this. Anyone know how to fix this?

 
Magento Community Magento Community
Magento Community
Magento Community
 
george_it
Jr. Member
 
Total Posts:  3
Joined:  2011-03-27
 

Hi,

I am also facing the same problem and want to take files off of our database.

Can anyone help?

George
I.T CameraAccess.com

 
Magento Community Magento Community
Magento Community
Magento Community
 
Vince RS
Jr. Member
 
Total Posts:  22
Joined:  2010-10-27
 

Just tried running this on a 1.5.0.1 install of Magneto but received the following error:

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near \\\\\\\’TRUNCATE TABLE `catalog_product_bundle_option`; TRUNCATE TABLE `catalog_product\\\\\\\’ at line 2

Can anyone help??

 
Magento Community Magento Community
Magento Community
Magento Community
 
sunil rajput
Jr. Member
 
Total Posts:  17
Joined:  2009-04-04
 

$pid is entity_id value.

You need to add is secure area statement if you are trying to delete record using standalone script.

Mage::register(’isSecureArea’, true);

try {
Mage::getModel(’catalog/product’)->load($pid)->delete();
} catch (Exception $e) {}

Mage::unregister(’isSecureArea’);

 
Magento Community Magento Community
Magento Community
Magento Community
 
NickFi
Jr. Member
 
Total Posts:  5
Joined:  2010-02-24
 

Works ok on 1.5.1.0

 
Magento Community Magento Community
Magento Community
Magento Community
 
XenonSupply
Jr. Member
 
Total Posts:  26
Joined:  2011-06-28
 

love it, thanks! helped me wipe my 3000+ test import entries.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Paulus
Guru
 
Total Posts:  335
Joined:  2008-07-21
 
NickFi - 29 June 2011 06:36 AM

Works ok on 1.5.1.0

Which one exactly? There’s several posted;-)

I’d love to know for 1.5.1.0

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top