Zen Cart Logo
If this is your first visit, check our documentation. To post, register or login.
Forums / Setting Up Your Zen Cart Products / Setting Up Categories, Products, Attributes / How to wipe clean all categories? with EP or otherwise?

How to wipe clean all categories? with EP or otherwise?

Started by goodfriendsam on 17 May 2013, 10:16 AM · Views: 652

Results 1 to 4 of 4
17 May 2013, 10:16 AM
#1
goodfriendsam avatar

goodfriendsam

New Zenner

Join Date:
May 2013
Location:
New London CT
Posts:
2
Plugin Contributions:
0

Post #1 by goodfriendsam

After multiple Easy Populate Upload updates, my products, which model numbers shifted around a couple times, now all have too many categories, and the wrong categories.

For example, product A used to be category 1 before the update; was category 2 after the update, but is now listed as both category 1 and 2 (let alone 3 and 4). It's a supplement store, so vitamin B whatever is now listed with the enemas, coconut oil is listed with olive oil, etc etc.

Wondering how to wipe the slate clean to reupload categories with easy populate? Have thousands of products, so doing it manually is not an option. I'm new and a bit skiddish about using phpmyadmin, but I understand that might be necessary.

Again, I want to delete the categories, but all other product information is fine.

Thank you.

http://www.groundedliving.net/onlinestore is the site (still under construction, and I hid the category cloud because it's so dysfunctional)

17 May 2013, 5:08 PM
#2
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Post #2 by kobra

I want to delete the categories, but all other product information is fine.
One can not delete the categories as they contain products which require belonging to some category

Zen-Venom Get Bitten

18 May 2013, 2:01 AM
#3
goodfriendsam avatar

goodfriendsam

New Zenner

Join Date:
May 2013
Location:
New London CT
Posts:
2
Plugin Contributions:
0

Post #3 by goodfriendsam

Thanks Kobra; appreciative of any ideas on how to navigate my dilemma.

18 May 2013, 2:33 AM
#4
drbyte avatar

drbyte

Sensei

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

Post #4 by drbyte

This SQL script will delete all categories except the lowest-numbered one, and re-assign all products to that category. Then you can manually add more categories and move products into those other categories.

SET @t1=0;
SELECT (@t1:= min(categories_id)) as t1 from categories;
delete from categories where categories_id != @t1;
delete from categories_description where categories_id != @t1;
truncate table products_to_categories;
insert into products_to_categories (products_id, categories_id) select products_id, @t1 from products;
update products set master_categories_id = @t1;
optimize table products, categories, categories_description;

Hopefully your site isn't using tablename prefixes. If it is, you'll need to adjust every tablename accordingly.

.
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.