Page 1 of 2 12 LastLast
Results 1 to 10 of 16
  1. #1
    Join Date
    Nov 2004
    Location
    Germany
    Posts
    106
    Plugin Contributions
    0

    Default Manually Set Category ID

    I match the category IDs in Zen-Cart with the product categories in my book keeping software.

    Unfortunately, I accidently deleted a category in Zen-Cart and need to add it again but with the same ID as before. In this case 59. When I add a new category the counter is at 88.

    Can I reset the counter to create the next category with the ID 59? If so where? The counters in Admin->Tools->Store Manager didn't seem to apply.

    If not is there a SQL statement that would work. Could someone give me an example?

    Thanks in advance.

    Patrick
    Leben und Wohnen im traditionellen amerikanischen Stil http://www.american-heritage.de

  2. #2
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Manually Set Category ID

    You would need to edit the two tables for:
    categories
    categories_name

    and change the categories_id to the one you deleted ...
    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!

  3. #3
    Join Date
    Nov 2004
    Location
    Germany
    Posts
    106
    Plugin Contributions
    0

    Default Re: Manually Set Category ID

    It worked but I also needed to change the category id of the products in the category since I forgot to move them first.

    To help anyone with a similar problem here are the commands I used. (make a backup before doing this just in case)


    update categories set categories_id = 59 where categories_id = 12;

    update categories_description set categories_id = 59 where categories_id = 12;


    Only if you forgot to move the products out of the old category!

    update products set master_categories_id = 59 where master_categories_id = 12;

    update products_to_categories set categories_id = 59 where categories_id = 12;

    Regards,

    Patrick
    Leben und Wohnen im traditionellen amerikanischen Stil http://www.american-heritage.de

  4. #4
    Join Date
    Sep 2008
    Location
    san diego, ca
    Posts
    30
    Plugin Contributions
    0

    Default Re: Manually Set Category ID

    Quote Originally Posted by Ajeh View Post
    You would need to edit the two tables for:
    categories
    categories_name

    and change the Categories_id to the one you deleted ...
    I would like to reset my categories ID to 0 after messing around with how I would like my categories set up. How do you edit the tables you mentioned above?

    Thanks much and great forum!

  5. #5
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Manually Set Category ID

    You mean reset to 0 so you can go move them to the proper Categories?

    NOTE: you cannot leave any left at 0 or you will run into conflicts with the pricing, sorting, searching etc.

    If you didn't have any Linked Products, you can run:
    PHP Code:
    UPDATE products_to_categories SET categories_id 0
    If you had Linked Products, then we need to get trickier on this ...
    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!

  6. #6
    Join Date
    Sep 2008
    Location
    san diego, ca
    Posts
    30
    Plugin Contributions
    0

    Default Re: Manually Set Category ID

    Thanks for the quick response. I don't have any products at all since this is my first install and set up with ZC.

    Sorry for the newbie question but where do I find that PHP code and how do I run it?

  7. #7
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Manually Set Category ID

    You can reset an empty table with the TRUNCATE TABLE command:

    Example, for categories you can use:
    Code:
    TRUNCATE TABLE categories;
    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!

  8. #8
    Join Date
    Sep 2008
    Location
    san diego, ca
    Posts
    30
    Plugin Contributions
    0

    Default Re: Manually Set Category ID

    Sorry but I'm so new at this php stuff that what you're telling me is Greek.

    Can you tell me how to do this without a command line? (This is what my host company told me to ask.) I have phpMyAdmin on my host account if that helps. It shows all the different fields like zen_categories but this shows no records at all.

    Thanks again!
    Last edited by roadliner; 21 Sep 2008 at 02:19 AM. Reason: thought this would help.

  9. #9
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Manually Set Category ID

    If you are not familiar with phpMyAdmin and the methods of reviewing the tables ... this is hard to tell you what to do and make sure that you are doing this safely ...

    So far, you said you had categories ...

    how did they get removed?

    Did you have products?

    Did you have Orders? Customers? etc. etc.

    An empty database table can have its auto increment reset to 1 by using the TRUNCATE command ...

    If the table name is categories you use:
    Code:
    TRUNCATE TABLE categories;
    If the table name is zen_categories, meaning you are using prefixes on your table names, then categories is zen_categories so you use:
    TRUNCATE TABLE zen_categories;

    If you are really uncertain as to what you are doing you can backup your database ...
    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!

  10. #10
    Join Date
    Sep 2008
    Location
    san diego, ca
    Posts
    30
    Plugin Contributions
    0

    Default Re: Manually Set Category ID

    I had categories but deleted them because I was figuring out how to lay out my categories. I don't have any products, orders or customers.

    So in phpMyAdmin, I see that the zen_categories has a Next Autoindex # of 16 which I want to reset to 0. How do I do this using phpMA?

    Worst case, I can delete this database and create a new one.

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. v139h manually set item with out of stock notice but not shut the item off?
    By djtrillian in forum General Questions
    Replies: 14
    Last Post: 21 Mar 2014, 06:56 PM
  2. Manually set site down
    By IntelCos in forum General Questions
    Replies: 10
    Last Post: 11 Jan 2009, 08:01 PM
  3. How to set a category folder as the default master category
    By april12345 in forum Setting Up Categories, Products, Attributes
    Replies: 0
    Last Post: 1 Sep 2008, 10:33 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg