Page 9 of 9 FirstFirst ... 789
Results 81 to 83 of 83
  1. #81
    Join Date
    Dec 2008
    Location
    Phoenix, AZ
    Posts
    28
    Plugin Contributions
    0

    Default Re: NOT WORKING IN V1.5.5f Re: How to hide categories with no active products

    Unfortunately, the code changes did not hide the categories with no products. When the switch is set to 1, I can still follow the menu to:

    "There are no products to list in this category."

    I suppose I need to hack some menu code to make that happen...

  2. #82
    Join Date
    Jul 2012
    Posts
    16,732
    Plugin Contributions
    17

    Default Re: NOT WORKING IN V1.5.5f Re: How to hide categories with no active products

    Quote Originally Posted by net3431 View Post
    Unfortunately, the code changes did not hide the categories with no products. When the switch is set to 1, I can still follow the menu to:

    "There are no products to list in this category."

    I suppose I need to hack some menu code to make that happen...
    With absence of detail, not sure which code chnages have been applied. The recommended code changes for ZC 1.5.5 were provided by the all wonderful Ajeh back in this post: https://www.zen-cart.com/showthread....47#post1265047

    Perhaps some post after offered further guidance, I did not look beyond that in my own short sightedness.
    Last edited by mc12345678; 5 Sep 2018 at 03:07 AM.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

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

    Default Re: NOT WORKING IN V1.5.5f Re: How to hide categories with no active products

    If you do not want to booger up your Zencart files and keep track of multiple files changing, run this code:

    PHP Code:
    //HIDE CATEGORIES AND SUBCATEGORIES WITH NO ACTIVE PRODUCTS
    $distict_cIDs $db->execute("select distinct `categories_id` from `" TABLE_CATEGORIES "` where `categories_id` not in (select `parent_id` from `" TABLE_CATEGORIES "`) ");
    foreach (
    $distict_cIDs as $ids) {
      
    $distinct_cID $distict_cIDs->fields['categories_id'];
      
    $mcid_to_status_count $db->execute("SELECT COUNT(`master_categories_id`) AS `NumberOfProducts` FROM `" TABLE_PRODUCTS "` WHERE `master_categories_id` = $distinct_cID and `products_status` = 1 ");
      
    $count $mcid_to_status_count->fields['NumberOfProducts'];
      if (
    $count == 0) {
        
    $db->execute("update " TABLE_CATEGORIES " set `categories_status` = 0 where `categories_id` = $distinct_cID ");
      }
    }
    //INCREASE < 3 AS NEEDED...THIS CODE, WITH THE ONE ABOVE WILL TAKE CARE OF 4 CATEGORIES/SUBCATEGORIES DEEP
    $i 0;
    while (
    $i 3) {
      
    $distict_cIDs $db->execute("select distinct `categories_id` from `" TABLE_CATEGORIES "` where `categories_id` in (select `parent_id` from `" TABLE_CATEGORIES "`) ");
      foreach (
    $distict_cIDs as $ids) {
        
    $distinct_cID $distict_cIDs->fields['categories_id'];
        
    $associated_subcategories_count $db->execute("SELECT COUNT(`categories_id`) AS `AssociatedSubcategoriesCount` FROM `" TABLE_CATEGORIES "` WHERE `parent_id` = $distinct_cID ");
        
    $subcategories_count $associated_subcategories_count->fields['AssociatedSubcategoriesCount'];
        
    $associated_subcategories_count_status_0 $db->execute("SELECT COUNT(`categories_id`) AS `SubcategoriesStatus0Count` FROM `" TABLE_CATEGORIES "` WHERE `parent_id` = $distinct_cID and `categories_status` = 0 ");
        
    $status_2_count $associated_subcategories_count_status_0->fields['SubcategoriesStatus0Count'];
        if (
    $subcategories_count == $status_2_count) {
          
    $db->execute("update " TABLE_CATEGORIES " set `categories_status` = 0 where `categories_id` = $distinct_cID ");
        }
      }
      
    $i++;

    I run it every time I check for supplier updates (twice a day).

    Ideally, plug it into the end of the ordering process so that it runs every time an order is completed.

    If you are smart enough to turn it into a "watcher class" please do and share with everyone.
    Last edited by mikeel100; 6 May 2020 at 09:33 PM. Reason: Details...

 

 
Page 9 of 9 FirstFirst ... 789

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