dkennelly Posted August 19, 2004 Share Posted August 19, 2004 Hi All, I need to set up a store with loads of categories but most will be empty for now - anyone know how I can use the categories box to display only categories with active products? Any help appreciated, thanks, daithi. Link to comment Share on other sites More sharing options...
winstanley_john Posted August 19, 2004 Share Posted August 19, 2004 Change the SQL query that returns a list of categories to only return categories that contain at least one active product. includes/boxes/categories.php http://spaces.msn.com/members/JohnWinstanley/ http://www.angelsolutions.co.uk Link to comment Share on other sites More sharing options...
dkennelly Posted August 19, 2004 Author Share Posted August 19, 2004 trying, but can't figure it out... any ideas? Link to comment Share on other sites More sharing options...
♥bruyndoncx Posted August 19, 2004 Share Posted August 19, 2004 although you can change the code to join categories with products, I don't think it is wise to do this as it puts a heavy burden on your system. I would install the enable/disable categories contribution which is a pretty easy install and it will not affect performance that much. KEEP CALM AND CARRY ON I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support). So if you are still here ? What are you waiting for ?! Find the most frequent unique errors to fix: grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt Link to comment Share on other sites More sharing options...
Guest Posted August 19, 2004 Share Posted August 19, 2004 There is a function already in categories.php that counts products in each category that will not place any extra burden on the system with more joined queries - if the count is 0 then don't display the link. Find: while ($categories = tep_db_fetch_array($categories_query)) { if ($level{$categories['parent_id']} == "") { $level{$categories['parent_id']} = 0; } $level{$categories['categories_id']} = $level{$categories['parent_id']} + 1; // Add category link to $categories_string for ($a=1; $a<$level{$categories['categories_id']}; $a++) { $categories_string .= " "; } Change to: while ($categories = tep_db_fetch_array($categories_query)) { if ($level{$categories['parent_id']} == "") { $level{$categories['parent_id']} = 0; } $level{$categories['categories_id']} = $level{$categories['parent_id']} + 1; $products_in_category = tep_count_products_in_category($categories['categories_id']); if ($products_in_category > 0) { // Add category link to $categories_string for ($a=1; $a<$level{$categories['categories_id']}; $a++) { $categories_string .= " "; } Find: else { tep_show_category($categories['categories_id'], $cPath_new, $COLLAPSABLE); } } } } ?> Change to: else { tep_show_category($categories['categories_id'], $cPath_new, $COLLAPSABLE); } } } } } ?> I just tested it and it works like a charm :D Link to comment Share on other sites More sharing options...
♥bruyndoncx Posted August 19, 2004 Share Posted August 19, 2004 Hi tony Good catch - just wondering if this also works if you don't show the product count ? KEEP CALM AND CARRY ON I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support). So if you are still here ? What are you waiting for ?! Find the most frequent unique errors to fix: grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt Link to comment Share on other sites More sharing options...
Guest Posted August 19, 2004 Share Posted August 19, 2004 Yes, it works both ways. I wrapped the display cat name function in the IF statement away from the display count test. :D Link to comment Share on other sites More sharing options...
niknakgroup Posted June 19, 2005 Share Posted June 19, 2005 hello, sorry to revive an old thread, but this may just be the answer to my prayers. I'm trying to run a sub-store with a manufacturer filter applied across the entire store. Anybody got a clue how I could add a manufacturer requirement into this category count, and therefore not show a category if no products by the relevant manufacturer in it?? Also, just for the record, I have been through both my includes/boxes/categories.php and the file which comes with the stock download, and I cant find the portion of code above - any ideas where this is? Thanks in advance! Please note - if I have suggested a contrib above, it doesnt mean it will work! Most of the contribs are not ones I've used, but may be useful for your particular problem.... Have you tried a refined search? Chances are your problem has already been dealt with elsewhere on the forums..... if (stumped == true) { return(square_one($start_over) } else { $random_query = tep_fetch_answer($forum_query) } Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.