Results 1 to 5 of 5
  1. #1
    Join Date
    Aug 2007
    Posts
    16
    Plugin Contributions
    0

    Default Delete empty categories?

    Hi,

    I am looking for a way (via SQL?) to easily delete all empty categories all the way up to the root.

    For example, if I have a third-level category that has no products, I need to delete it. Then, if it's parent category (on level 2) has no other categories, I need to delete that too, etc. etc. all the way back up to the root categories.

    Please can somebody point me in the right direction. I'm not afraid of SQL, if you can tell me where I need to be looking.

    Best wishes,

    Sigol.

  2. #2
    Join Date
    Aug 2007
    Posts
    16
    Plugin Contributions
    0

    Default Re: Delete empty categories?

    Sorry to bump this but I'm a bit desperate. Anybody help?

    Thanks in advance.

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

    Default Re: Delete empty categories?

    There really isn't a simple method to delete Categories en masse that have no products built into Zen Cart, at this time ...
    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!

  4. #4
    Join Date
    Aug 2007
    Posts
    16
    Plugin Contributions
    0

    Default Re: Delete empty categories?

    Hi Ajeh,

    Thank you for your reply. I appreciate there may be no ready-made function that deletes empty categories. What I am looking for is an algorithm that I can use to build SQL from.

    For instance, for a given category, say ID=x, if the following two statements were true:

    1. (select count(*) from products where master_categories_id = x) = 0
    2. (select count(*) from categories where parent_id = x) = 0

    ...then would it be safe to delete category x ?

    Thanks,

    sigol.

  5. #5
    Join Date
    Jan 2004
    Posts
    66,444
    Plugin Contributions
    279

    Default Re: Delete empty categories?

    Don't use master_categories_id. Use products_to_categories.
    .

    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.

 

 

Similar Threads

  1. OK to delete empty subdirectories?
    By ima_newb in forum General Questions
    Replies: 3
    Last Post: 8 Nov 2009, 08:56 PM
  2. Empty space - below logo and below Home & Log in links - how to delete?
    By dabone in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 21 Jan 2009, 01:18 AM
  3. All customers fields in ADMIN > CUSTOMERS are empty and I can't delete them!
    By plgaudreau in forum Managing Customers and Orders
    Replies: 1
    Last Post: 26 Feb 2008, 02:08 AM

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