Page 2 of 9 FirstFirst 1234 ... LastLast
Results 11 to 20 of 83
  1. #11
    Join Date
    Sep 2012
    Location
    West Jefferson, NC
    Posts
    383
    Plugin Contributions
    0

    Default Re: How to hide categories with no active products

    Just so you know, I did copy /includes/templates/templates_default/sideboxes/tpl_categories.php
    and place it in my customized folder... /includes/templates/MY_FILES/sideboxes/tpl_categories.php

  2. #12
    Join Date
    Sep 2012
    Location
    West Jefferson, NC
    Posts
    383
    Plugin Contributions
    0

    Default Re: How to hide categories with no active products

    Quote Originally Posted by mikeel100 View Post
    Did you try Configuration->Layout Settings->Categories with 0 Products Status ... and set it to 0 (off)?
    Yes, I'm talking to myself again...LOL. Need a break.

  3. #13
    Join Date
    Sep 2012
    Location
    West Jefferson, NC
    Posts
    383
    Plugin Contributions
    0

    Default Re: How to hide categories with no active products

    Quote Originally Posted by mikeel100 View Post
    That made all of my categories disappear...here is the code that I modified with your suggestion.

    if (zen_get_product_types_to_category($box_categories_array[$i]['path']) == 3 or ($box_categories_array[$i]['top'] != 'true' and SHOW_CATEGORIES_SUBCATEGORIES_ALWAYS != 1) or $box_categories_array[$i]['count'] == 0) {
    // skip if this is for the document box (==3)
    // skip if this category has no active products MIKE
    } else {
    $content .= '<a class="' . $new_style . '" href="' . zen_href_link(FILENAME_DEFAULT, $box_categories_array[$i]['path']) . '">';
    if (zen_get_product_types_to_category($box_categories_array[$i]['path']) == 3 or ($box_categories_array[$i]['top'] != 'true' and SHOW_CATEGORIES_SUBCATEGORIES_ALWAYS != 1) or $box_categories_array[$i]['count'] == 0) {
    // skip if this is for the document box (==3)
    // skip if this category has no active products MIKE
    WHAT DO I NEED TO COMMENT OUT BELOW TO MAKE IT SKIP
    } else {
    $content .= '<a class="' . $new_style . '" href="' . zen_href_link(FILENAME_DEFAULT, $box_categories_array[$i]['path']) . '">';
    Ignore the double code above...I must have double pasted when I was replying. The code in my file is not doubled like it is above...

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

    Default Re: How to hide categories with no active products

    I forgot ... you probably have set this to false:
    Show Category Counts
    Count recursively how many products are in each category
    Turn that to true ...

    Now, starting with a clean:
    /includes/templates/templates_default/sideboxes/tpl_categories.php

    using your templates and overrides make the following changes in RED:
    Code:
         if (zen_get_product_types_to_category($box_categories_array[$i]['path']) == 3 or ($box_categories_array[$i]['top'] != 'true' and SHOW_CATEGORIES_SUBCATEGORIES_ALWAYS != 1 or $box_categories_array[$i]['count'] == 0)) {
            // skip if this is for the document box (==3)
          } else {
          $content .= '<a class="' . $new_style . '" href="' . zen_href_link(FILENAME_DEFAULT, $box_categories_array[$i]['path']) . '">';
    Then change the code:
    Code:
          if (false && SHOW_COUNTS == 'true') {
            if ((CATEGORIES_COUNT_ZERO == '1' and $box_categories_array[$i]['count'] == 0) or $box_categories_array[$i]['count'] >= 1) {
              $content .= CATEGORIES_COUNT_PREFIX . $box_categories_array[$i]['count'] . CATEGORIES_COUNT_SUFFIX;
            }
          }
    So while you say show the counts in configuration ... you will not show the counts but will still gather the counts so that categories with 0 Products will not show ...

    Does this work better for you?
    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: v1.5.5]
    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!

  5. #15
    Join Date
    Sep 2012
    Location
    West Jefferson, NC
    Posts
    383
    Plugin Contributions
    0

    Default Re: How to hide categories with no active products

    Where, in zencart, are the calculations done for making the, ## of ## active, display next to the green/red buttons in admin/categories? That is the info I need to make a simple MySQL code work for this issue.

    I've posted the post below at stackoverflow to try and help find a solution as well...http://stackoverflow.com/questions/1...egory-are-zero


    First off, let me say I am a NOVICE MySQL programmer. I appreciate any help I can get.

    I am trying to update a record value in one table where the count of records in a separate table are equal to the count of records in another table where a certain criteria is met.

    In real language: Within a specific category, if all of the products_status, in table products, are set to 0 (not active), then I want to set the category_status, in table category, to 0 (hidden).

    I'll explain my thought process after I give you a little background info.

    The relevant parts of my categories table are: categories_id (unique and autoincremented) categories_status (0 or 1) parent_id

    The relevant parts of my products table are: products_id (autoincremented) products_status (O or 1) master_categories_id (I believe it is linked to the categories_id column n the categories table)

    The products_to_categories table has two columns: products_id categories_id

    Now, this is what I am attempting:

    1. Go to the first record of categories.categories_id and set that as a variable (CategorySearchID).

    2. Go to products.master_categories_id and count the number of records that match the CategorySearchID and set that to a variable (CategorySearchIDCount). This gives the total number of products in that CategorySearchID.

    3. Go to products.products_status and count all records that have a product_status of 0 where the CategorySearchID is a match.

    4. Compare the counts in step 2 and 3. If they are equal, the categories.category_status for the current CategorySearchId will be set to 0 (hidden).

    5. Finally, I need a loop that will search through all categories.category_id (CategorySearchID) and do the count comparisons and status updates in steps 2, 3 and 4.

    I have tried dozens of combinations of the following code but keep getting errors. I can get some of the individual element of the code to work but I can't seem to tie them all together.

    For example:

    UPDATE DATABASE.categories SET categories_status = 0

    Sets all category_status' to 0 successfully

    SELECT COUNT(products_id) FROM products WHERE products_status=0

    Finds all of the products_status' set to 0 and returns the number in a temporary table.

    AND parent_id != 0;

    Prevents top level categories from being set to hidden

    I'm not going to bore you with all of the combinations I've tried.

    Again, I really would appreciate any help!

    Mike

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

    Default Re: How to hide categories with no active products

    In the Class category_tree.php the counts are made and the tree made for the sidebox ...

    With only the changes that I posted, for only the tpl_categories.php file, Only Categories that contain Active Products are showing ... NOTE: you need the Category Counts turned on in the settings to know which Categories to show or exclude, but the counts will still be hidden based on the code changes that I posted ...

    Have you additional changes that might be causing this to not work for you?
    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: v1.5.5]
    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!

  7. #17
    Join Date
    Sep 2012
    Location
    West Jefferson, NC
    Posts
    383
    Plugin Contributions
    0

    Default Re: How to hide categories with no active products

    Your a life saver and a genius Ajeh! Thanks!

    I believe this will work! No need to manually change CATEGORY buttons from green to red now!

    It's not affecting searches neither!

    I can sleep tonight...LOL.

    I'll post this answer into the other threads I ran across where nobody found a solution to.
    Last edited by mikeel100; 9 Jul 2013 at 02:51 AM. Reason: P.S.

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

    Default Re: How to hide categories with no active products

    Thanks for the update that this did work for you ...
    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: v1.5.5]
    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!

  9. #19
    Join Date
    Sep 2012
    Location
    West Jefferson, NC
    Posts
    383
    Plugin Contributions
    0

    Default Re: How to hide categories with no active products

    Quote Originally Posted by Ajeh View Post
    Thanks for the update that this did work for you ...
    No, thank you! I have ran across so many topics where people left me hanging for an answer...I didn't want to do that to anyone else. It's very frustrating. :)

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

    Default Re: How to hide categories with no active products

    Always a pleasure ... remember the Zen Cart Team when you are rich and famous!
    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: v1.5.5]
    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!

 

 
Page 2 of 9 FirstFirst 1234 ... LastLast

Similar Threads

  1. v150 how do i hide sub categories with no products listed
    By alibaba99 in forum Templates, Stylesheets, Page Layout
    Replies: 2
    Last Post: 28 Jan 2017, 06:19 PM
  2. Hide Categories with 0 Products
    By Semenek in forum Setting Up Categories, Products, Attributes
    Replies: 2
    Last Post: 4 Sep 2010, 05:44 PM
  3. Hide categories/subcategories with no products
    By earthone in forum Basic Configuration
    Replies: 0
    Last Post: 22 Jul 2010, 09:38 PM
  4. Active products in categories box
    By ouxly40 in forum Templates, Stylesheets, Page Layout
    Replies: 2
    Last Post: 26 Sep 2007, 11:46 AM
  5. How to hide sub-categories with no active products?
    By donplay in forum Setting Up Categories, Products, Attributes
    Replies: 5
    Last Post: 29 Aug 2007, 08:20 PM

Bookmarks

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
Zen-Cart, Internet Selling Services, Klamath Falls, OR