Zen Cart Logo
Forums / Setting Up Categories, Products, Attributes / Deleting secondary category - keep master category

Deleting secondary category - keep master category

Locked

Views: 2,607

Results 1 to 10 of 10
This thread is locked. New replies are disabled.
21 Nov 2008, 5:17 PM
#1
stalb33 avatar

stalb33

New Zenner

Join Date:
Oct 2008
Posts:
55
Plugin Contributions:
0

Deleting secondary category - keep master category

Hi. Somehow a lot of my products have been linked together. I want to delete all secondary categories. I know I can go in one by one and delete the secondary and keep the master category. However, there are thousands of products to check thru. Please help.

21 Nov 2008, 6:18 PM
#2
fairestcape avatar

fairestcape

Totally Zenned

Join Date:
Mar 2008
Location:
Cape Town & London (depends on the season)
Posts:
2,957
Plugin Contributions:
0

Re: Deleting secondary category - keep master category

There is no "Magic Bullet" for these sorts of tasks, but you may be able to work more efficiently by using easypopulate.

Install Easypopulate (if you don't yet have it) and then get it to dump your product data.

Get this into a spreadsheet, and using column sort features, list products by product name, then by category1, category2, etc.

You will then be able to see which products are duplicated by categories, and can delete them before tidying up the spreadsheet and re-importing into ZC.

See the WIKI for a tutorial on Easy Populate)

21 Nov 2008, 7:42 PM
#3
ajeh avatar

ajeh

Oba-san

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

Re: Deleting secondary category - keep master category

You could rebuild the products_to_categories table from the products table ...

IF the master_categories_id is the correct categories_id for ALL of your products ... the products_to_categories table can be rebuilt by going to phpMyAdmin and:

1 BACK UP the products_to_categories table

2 SEE 1

3 Truncate the products_to_categories table

4 Don't you wish you did that backup?

5 Now rebuild the products_to_categories table from the products table using the products_id and master_categories_id by running the following SQL statement:

insert into products_to_categories (products_id, categories_id) select products.products_id as products_id, products.master_categories_id as categories_id from products

Now ... think about how happy you are?

Next, think about all the time that was saved ... including your neck ...

Now don't you wish you could buy the Zen Cart Team a cup of coffee? perhaps a few donuts? take us out to lunch? buy us the best steak dinner in the world?!? er ... sorry ... got carried away there ... :cool:

Don't forget us when you are rich and famous ...

21 Nov 2008, 7:50 PM
#4
fairestcape avatar

fairestcape

Totally Zenned

Join Date:
Mar 2008
Location:
Cape Town & London (depends on the season)
Posts:
2,957
Plugin Contributions:
0

Re: Deleting secondary category - keep master category

Ajeh:

Now ... think about how happy you are?

You see? You don't need stories of doom and gloom from ME when there are experts in the fold! :clap:

21 Nov 2008, 8:02 PM
#5
ajeh avatar

ajeh

Oba-san

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

Re: Deleting secondary category - keep master category

You have no idea how many times I messed with the syntax before I got that right ... I would not get the expert award ... but I would get an A+ for effort ... :cool:

Less is more on defining the fields in the INTO and FROM tables ... :rolleyes:

25 Nov 2008, 3:24 PM
#6
stalb33 avatar

stalb33

New Zenner

Join Date:
Oct 2008
Posts:
55
Plugin Contributions:
0

Re: Deleting secondary category - keep master category

That really helps. It will still take me some time to figure out how to actually DO what you have described. I'm still new to the sql part of this. thanks though

1 Jul 2010, 3:40 PM
#7
jmcqueen avatar

jmcqueen

New Zenner

Join Date:
Oct 2004
Posts:
75
Plugin Contributions:
0

Re: Deleting secondary category - keep master category

if i have linked products to multiple categories, can someone please tell me which table contains the linked-to categories? i want to do the update in steps on the following example:

Lets say...

Item 1 master category is '25'
Item 1 is linked to category '18'

Step 1:
I want to remove the linkage via an SQL statement to drop linked category '18' from the item.

Step 2:
I want to update the master category to '31' via an SQL statement.

The following SQL statement works to move the master category to '31' but the linked-to category '18' is still attached like a leach!

UPDATE products p
SET p.master_categories_id = '31'
WHERE p.products_quantity = '0'
AND p.products_sort_order = '100'

any help on this one would be greatly appreciated.

10 Sep 2010, 7:11 PM
#8
notageek avatar

notageek

Zen Follower

Join Date:
Mar 2009
Posts:
418
Plugin Contributions:
0

Re: Deleting secondary category - keep master category

I tried to use the Multiple Categories Links Manager to copy products to a new category. I went to Admin>Catalog>Category>Product, selected a product, selected the "C" to copy, selected "duplicate" as the copy method (instead of link), and chose the Multiple Categories Links Manager at the bottom. A list of the 12 products appeared, and in the checkbox area the current subcategory was selected.

I had selected "duplicate" instead of link, so I interpreted the warning that changing linked categories without setting the master category would cause problems to not apply to duplicate operations which were not linking operations.

I then chose the last choice under "Global Category Link Changes and Master Category ID Reset" which states:

Reset ALL Products in the selected Category to use the selected Category as the new Master Categories ID ...
Example: Resetting Category 22 would set ALL Products in Category 22 to use Category 22 as the Master Category ID,"

Reset ALL Products in the selected Category to use the selected Category as the new Master Categories ID ...
Example: Resetting Category 22 would set ALL Products in Category 22 to use Category 22 as the Master Category ID

and wrote in the new category number (I unchecked the current category in the check boxes area above). In other words, Category 23 in the example being the new category, I selected Category 23.

What then happened was that, instead of moving the products to the Category 23, it set a master category for Category 22 to Category 22, just as it said it would.

Now that they are set with master category 22, I am not sure how to change them to Category 23. I plan to delete category 22. If the products become linked, I would need to change the master category and then delete the link.

I seem to be missing the point of the instructions here, and can't find a step-by-step tutorial.

Thanks for any help.

11 Sep 2010, 6:07 PM
#9
notageek avatar

notageek

Zen Follower

Join Date:
Mar 2009
Posts:
418
Plugin Contributions:
0

Re: Deleting secondary category - keep master category

Regarding Post No. 7, in performing a change of products from one category to another, using the Multiple Categories Links Manager, for which I will describe steps below (for the next novice experiencing concern over the process), I also experienced that the links are very persistent, which is a good thing.

I was, however, able to go to the original product category and remove the linked products from that category, after re-setting the master category.

Here are the steps I followed to move products from one category to another:

  1. Begin as stated in Post 8.

  2. Just above the chart of categories checkboxes, confirm the master category (eg., as 22).

  3. Select the master category and the new category checkboxes. (Be sure the new category has been created.)

  4. From the bottom box entitled "Global Category Link Changes and Master Category Reset" select the 1st choice, i.e., the copy function:

Copy ALL Products in a Category as LINKED Products to another Category ...

  1. The products will be copied (e.g., from category 22 to category 23).

  2. With categories still selected (e.g., 22 and 23) in the categories checkboxes area, choose the 3rd choice in the "Global..." box, filling in the new master category number [23]:

Reset ALL Products in the selected Category to use the selected Category as the new Master Categories ID ..

  1. The master category reset will show as confirmed by the yellow filling of the category [23] in the categories checkboxes area.

  2. If you want to remove the former category [22], you may need to leave this Multiple Categories Links Manager screen and navigate to the category [22] (or products) and delete it, as I did, to complete the process of transferring the products to a new category.

I do not know how to use the second function in the "Global..." box:

Remove ALL Products in a Category that are LINKED Products to another Category ...

That command did not unlink the categories for me. Instead it gave me the big pink warning at the top stating:

New Master Category ID Conflict. . . 22 conflicting to category 23. . . .

I could not figure out how to remove the link at all, even how to unlink a single product in the products listing screen. Clicking on the yellow link symbol itself just took me to the product editing screen.

However, since I wanted to delete the category, as opposed to just unlinking it, I went to the location of category 22 and just deleted it. This was successful.

Having gone through this whole process, it seems logical.

It also seems that there is some sort of memory causing the Zen Cart to keep links and prevent disturbance of links, so that it seems on my system I need to wait a while before the cart will accept new data when dealing with the links manager.

Also, on my computer, I know to wait quite a while for a computer response, which would seem to indicate that this process of moving and linking and resetting products and categories may understandably be utilizing quite a lot of memory.

So, there is my step-by-step for moving products to another category. It wasn't as straightforward for me as I set forth above, but now that I have been through it, hopefully it will go more smoothly next time.

I hope this is helpful to someone.

Notageek