Zen Cart Logo
If this is your first visit, check our documentation. To post, register or login.
Forums / General Questions / General Questions / Delete all products?

Delete all products?

11 Feb 2013, 4:37 PM
#21
philip937 avatar

philip937

Totally Zenned

Join Date:
Aug 2009
Location:
Bedford, England
Posts:
968
Plugin Contributions:
0

Post #21 by philip937

oh do you mean if say you had prod ids 1-1000

and you delete 500-1000 using easy poulate the next product will be 1001

so it would go 1-500, 1001 - ...

and if you did it manually ? then what the product id is re-used for new products?

Phil Rogers
A problem shared is a problem solved.

11 Feb 2013, 6:53 PM
#22
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,512
Plugin Contributions:
176

Post #22 by drbyte

philip937:

oh do you mean if say you had prod ids 1-1000

and you delete 500-1000 using easy poulate the next product will be 1001

so it would go 1-500, 1001 - ...
Yes. Deleting via EP or by manually hacking things out of the tables, or even by deleting one-by-one via the ZC admin console will leave gaps in numbers.

Using EP to delete is not what the OP was asking about in starting this thread. He/She wanted to wipe everything and presumably start from 1.

My post was merely pointing out that EP is not the right tool to accomplish that desired result.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

11 Feb 2013, 7:00 PM
#23
philip937 avatar

philip937

Totally Zenned

Join Date:
Aug 2009
Location:
Bedford, England
Posts:
968
Plugin Contributions:
0

Post #23 by philip937

how do I delete all products from my zencart store without actually going through each one? My store has 18000+ products, I need to delete all of them so I can reinstall them with the proper format...I installed ez populate, and uploaded all of them but left a single space in the image URL so none of the images show up...I need to go in delete all the old products and resubmit with the updated info...please help.

Don't remember seeing a anything about starting from 1 anywhere, however I did misread the original post.

If all you want to do is correct your mistake, you just download the cab of all your products, correct te mistake on the csv, then re-upload. Job done.

Phil Rogers
A problem shared is a problem solved.

11 Feb 2013, 7:07 PM
#24
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,512
Plugin Contributions:
176

Post #24 by drbyte

See, this is why it's a bad idea for people to hijack others' threads.
You quoted the first OP, from Aug 2007.

I was responding to the Feb 2013 post by dancingbay:> dancingbay:

I want to delete all the products and categories. I loaded the test data with my install, but want to remove it all and start fresh

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

11 Feb 2013, 7:08 PM
#25
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,512
Plugin Contributions:
176

Post #25 by drbyte

And now dancingbay has started a new thread: http://www.zen-cart.com/showthread.php?205860-EasyPopulate-Questions

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

11 Feb 2013, 7:14 PM
#26
philip937 avatar

philip937

Totally Zenned

Join Date:
Aug 2009
Location:
Bedford, England
Posts:
968
Plugin Contributions:
0

Post #26 by philip937

Oh good grief total confusion! Brain fart!

Phil Rogers
A problem shared is a problem solved.

11 Feb 2013, 7:16 PM
#27
schoolboy avatar

schoolboy

Totally Zenned

Join Date:
Jun 2005
Location:
Cumbria, UK
Posts:
10,327
Plugin Contributions:
0

Post #27 by schoolboy

DrByte:

My post was merely pointing out that EP is not the right tool to accomplish that desired result.

The products use an Auto-incremented ID number - a feature of databases, which ensures that a record that requires a unique identifier, is allocated one.

This facilitates a range of options - one of the more important being to use the RELATIONAL features in a database. Other tables are able to "associate" a line of data against an established field ID - an thereby "relate" to it. This allows for considerable "compression" of information, because instead of having to duplicate (or triplicate, or quadruplicate) a line of data across several tables, one cross-references the tables and fields by using these unique ID's.

In order to ensure that NO "confusion" can exist in this "relationship" process, a database will NOT re-issue, or re-use an ID. In the general scheme of things, an ID "dies" with a record to which it applies, and the value continues to increment numerically.

Truncating a table will reset the Auto Increments to "1".

But beware... you may end up truncating only SOME of the tables which reference the product_id, meaning they are re-set to a value of "1", but you may forget to truncate others where product_id is listed. These will contain the stream of product_id's - so you will end up with one table saying product_id ### relates to "A", and another saying product_id ### relates to "B", or "C"...

This vital "checking mechanism" is rigorously protected in the normal operation of a database, mainly because having conflicts can wreak such havoc.

easypop will not reset this value... hence Dr Byte indicating that the BEST way of ensuring a "clean" database is to start from scratch. The risk of not doing this is considerable.

20 years a Zencart User

12 Feb 2013, 10:41 AM
#28
philip937 avatar

philip937

Totally Zenned

Join Date:
Aug 2009
Location:
Bedford, England
Posts:
968
Plugin Contributions:
0

Post #28 by philip937

I think I understand that. Thanks for explaining :-)

Just out of curiosity, if you export a table. Then drop the table, then import the file you exported, does it carry on where it left off as if it never was gone?

Phil Rogers
A problem shared is a problem solved.

12 Feb 2013, 2:18 PM
#29
schoolboy avatar

schoolboy

Totally Zenned

Join Date:
Jun 2005
Location:
Cumbria, UK
Posts:
10,327
Plugin Contributions:
0

Post #29 by schoolboy

philip937:

I think I understand that. Thanks for explaining :-)

Just out of curiosity, if you export a table. Then drop the table, then import the file you exported, does it carry on where it left off as if it never was gone?

An export will contain ALL the configurations AND content of a table, and lets say there are NINE HUNDRED AND FOURTEEN RECORDS (914) with the export - then the CREATE TABLE command will indicate that Auto-increment must start at 915.

20 years a Zencart User

12 Feb 2013, 3:06 PM
#30
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,512
Plugin Contributions:
176

Post #30 by drbyte

schoolboy:

An export will contain ALL the configurations AND content of a table, and lets say there are NINE HUNDRED AND FOURTEEN RECORDS (914) with the export - then the CREATE TABLE command will indicate that Auto-increment must start at 915.
Addendum: if there HAS EVER BEEN 914 records in the table and any of them have been deleted, the auto-increment will still say 915 for the next record. That's how auto-increment works. Mussing with that feature can leave you in a pickle if all the related tables aren't cleared of all traces of corresponding records. Be careful what you do there. You could completely cripple your site if you go fooling with autoincrements.

But now we're WAY OFF TOPIC AGAIN.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

12 Feb 2013, 3:09 PM
#31
schoolboy avatar

schoolboy

Totally Zenned

Join Date:
Jun 2005
Location:
Cumbria, UK
Posts:
10,327
Plugin Contributions:
0

Post #31 by schoolboy

DrByte:

But now we're WAY OFF TOPIC AGAIN.

But it's a critically important issue...

Perhaps a wiki on this subject?

I'd be happy to start such a topic...

20 years a Zencart User

2 Oct 2015, 3:40 PM
#32
san0425 avatar

san0425

New Zenner

Join Date:
Oct 2015
Location:
Delhi, India
Posts:
1
Plugin Contributions:
0

Post #32 by san0425

Here I am explaining the way "How to delete all products from your Zencart store without actually going through one by one".
https://youtu.be/30CGjprwPqo

There are two options:
1 - Delete products one by one from ZenCart admin panel
2 - Delete all products in ZenCart from phpMyAdmin

If you have less products than option 1 is good.
But if you have more than 500+ or 1000+, then it becomes very difficult to delete one by one. So to delete all the products and categories, the best way is option 2 using phpMyAdmin.

You can use below SQL statements to truncate product and category tables, listed below:

TRUNCATE zen_categories;
TRUNCATE zen_categories_description;

TRUNCATE zen_products;
TRUNCATE zen_products_attributes;
TRUNCATE zen_products_attributes_download;
TRUNCATE zen_products_description;
TRUNCATE zen_products_discount_quantity;
TRUNCATE zen_products_notifications;
TRUNCATE zen_products_options;
TRUNCATE zen_products_options_values;
TRUNCATE zen_products_options_values_to_products_options;
TRUNCATE zen_products_to_categories;

Thats it!

If you feel any difficulty, please feel free to contact us.

2 Oct 2015, 3:56 PM
#33
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Post #33 by ajeh

There is more to it than that ...

You might want to also address things like:
Specials
Featured
Reviews
etc. etc. etc

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

2 Oct 2015, 3:58 PM
#34
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Post #34 by mc12345678

san0425:

Here I am explaining the way "How to delete all products from your Zencart store without actually going through one by one".
https://youtu.be/30CGjprwPqo

There are two options:
1 - Delete products one by one from ZenCart admin panel
2 - Delete all products in ZenCart from phpMyAdmin

If you have less products than option 1 is good.
But if you have more than 500+ or 1000+, then it becomes very difficult to delete one by one. So to delete all the products and categories, the best way is option 2 using phpMyAdmin.

You can use below SQL statements to truncate product and category tables, listed below:

TRUNCATE zen_categories;
TRUNCATE zen_categories_description;

TRUNCATE zen_products;
TRUNCATE zen_products_attributes;
TRUNCATE zen_products_attributes_download;
TRUNCATE zen_products_description;
TRUNCATE zen_products_discount_quantity;
TRUNCATE zen_products_notifications;
TRUNCATE zen_products_options;
TRUNCATE zen_products_options_values;
TRUNCATE zen_products_options_values_to_products_options;
TRUNCATE zen_products_to_categories;

Thats it!

If you feel any difficulty, please feel free to contact us.

Fyi, this assumes that 1) the tables have a prefix of zen_ and 2) no other table(s) have been generated to support a plugin that references product in the database.

Also it is suggested to review the discussion of the previous page(s) in relation to this topic..

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

2 Oct 2015, 7:21 PM
#35
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,156
Plugin Contributions:
56

Post #35 by lat9

Your best bet is to create a "simple" admin-level php script that uses the built-in admin function to remove each product:

require ('includes/application_top.php');
$products = $db->Execute ("SELECT products_id FROM " . TABLE_PRODUCTS);
while (!$products->EOF) {
  zen_remove_product ($products->fields['products_id']);
  $products->MoveNext ();
}
require ('includes/application_bottom.php');

That script might need some "scaffolding" (like a dummy language file) to allow it to run from your admin folder, but the code above has the gist.

2 Oct 2015, 8:35 PM
#36
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Post #36 by mc12345678

lat9:

Your best bet is to create a "simple" admin-level php script that uses the built-in admin function to remove each product:

require ('includes/application_top.php');
$products = $db->Execute ("SELECT products_id FROM " . TABLE_PRODUCTS);
while (!$products->EOF) {
zen_remove_product ($products->fields['products_id']);
$products->MoveNext ();
}
require ('includes/application_bottom.php');

> That script might need some "scaffolding" (like a dummy language file) to allow it to run from your admin folder, but the code above has the gist.

FWIW, due to the conversation's coverage and directional change, this suggestion would function the same as using Easy Populate v4 to delete the product.  The use of an Easy Populate program as applicable to this thread was discussed on the previous page.

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...