Finished - Addon To Hide Empty Categories

Well, I had tbirnseth create a mod for me that would filter out empty categories.



I turned it into its own addon and figured I'd share it on here.



Basically it filters out any categories that match this criteria:



Categories containing products of status 'D' or 'H' and have an inventory <= 0 (values are product counts of qualifying products)



That last part was tbirnseth's words.



This addon doesn't change the status of a category, it just filters it out so the customers can't see it. Kind of a long story about why it doesn't change the status, but tbirnseth was right in making this way and pointed out some great reasons.



Installation is really easy.



1.) Move the hide_categories addon into your addons folder

2.) Go to Admin => Administration => Addons => Install the Hide Categories addon

3.) Clear you cache

4.) It is installed



To use the addon:



1.) Go to Admin => Catalog => Click on the link circled in blue:





2.) You'll end up with a list of categories that are filtered out like:







3.) That's it. Now you customers can't see those categories.



If you add products or make products active that are in those categories, just run the Compress Categories link again and it will unhide them.



I'll mainly use this after I do product imports, but I'm sure other people can use it for different things.



One thing though. This addon is more advanced than what I am capable of doing so I can't really guarantee any kind of support. I'm sure tbirnseth will support this, but since it isn't an addon that he is releasing, I doubt he'll support it for free.



Anyways, there you go. Hopefully someone here can use this.



Brandon



Ps. I can't remember what version this is for, but I know it isn't compatible with 3.x.

hide_categories.zip

Thanks a lot, i’m testing it,it’s wonderful :slight_smile:

all is oki !



Very good job !

brandon, thanks for sharing :slight_smile:

I'm using the last version of cs-cart and after I run your add-on in the admin pages this error shows up: "Bad category_id 0 "



Empty categories are not removed, instead non-empty catehories are (in a random pattern).



Any ideas?

I haven't switched any of my stores that have this addon to version 2.2.1 yet so I have no clue what would be wrong. Honestly, I probably wouldn't have a clue anyways since this type of thing is beyond my knowledge, which is why I hired Tony.



I'll contact Tony and see what he says. He is very good at keeping his addons updated on the subversion level, but this is a brand new version so he'll probably want to charge. I'll see how much he wants. If it is within my current budget, I'll just pay it and post the updated version on here. If it is outside of my budget, would you be willing to pitch in a few bucks?



Thanks,



Brandon

Brandon,

I don't seem to have a copy of this around. If you want to send me the archive, I can look for the error and see what's up. My guess is that there's some config problem in the merchant's store where a category does not exist where something in the store (like the product_categories table) thinks it should exist.

Well Tony of course came up with a solution and I didn't even have to ask. Pretty darn cool.



I've attached a V2 of the Hide Categories Addon. This should work with 2.1.4 or 2.2.1.



I hope it helps. And don't forget to thank Tony.



Thanks,



Brandon

hide_categories.zip

Note that the change had nothing to do with the version. The issue is that the merchant has a bad category entry (category_id = 0) in their product_categories table and a category with that ID does not exist. I simply skip categories with category_id == 0…



Note that Brandon has the archive built in a way that you will need to extract and copy files versus simply extracting into the root of your store.

I just updated the file so that it should be able to just be uploaded and un-compressed.



Tony, does it look right now?



Thanks,



Brandon

Yep, everything is now relative to the root directory of a store.

Doesn't appear to be working for 2.2.1? (I downloaded the zip file from: 18 July 2011 - 06:00 AM)



After running, and a page or two of category names with green background is displayed, I viewed the home page, and still can see categories that are empty - and sub-categories within those which are also empty.



It doesn't appear to have hidden anything.



And where is this file people are talking about? When you run this, does it create some sort of log or backup?



Thanks for everyones help!

Cheers!

[quote name='UniDevelopers' timestamp='1317788154' post='122938']

Doesn't appear to be working for 2.2.1? (I downloaded the zip file from: 18 July 2011 - 06:00 AM)



After running, and a page or two of category names with green background is displayed, I viewed the home page, and still can see categories that are empty - and sub-categories within those which are also empty.



It doesn't appear to have hidden anything.



And where is this file people are talking about? When you run this, does it create some sort of log or backup?



Thanks for everyones help!

Cheers!

[/quote]



Did you clear your cache?

[font=“Verdana”]Yes, of course :P



If there are 15 sub-categories, with 10 sub-categories with products within, and 200 products. This addon, in my case, will show only 2 sub-categories, but will show all 200 products!



It does not take in to account SECONDARY CATEGORIES! (It appears to me…)

Or there is some other major loop hole in the logic :(



Would appreciate an update! :)



Client has Professional licence. Will test with client on Multi-Vendor, i hope they haven’t updated yet to 2.2.2/2.2.3.



Thanks![/font]

I can confirm, this is the same problem we are having. It doesn’t hide sub-categories with no products in them.


[quote name=‘UniDevelopers’ timestamp=‘1317880333’ post=‘123002’]

[font=“Verdana”]Yes, of course :P



If there are 15 sub-categories, with 10 sub-categories with products within, and 200 products. This addon, in my case, will show only 2 sub-categories, but will show all 200 products!



It does not take in to account SECONDARY CATEGORIES! (It appears to me…)

Or there is some other major loop hole in the logic :(



Would appreciate an update! :)



Client has Professional licence. Will test with client on Multi-Vendor, i hope they haven’t updated yet to 2.2.2/2.2.3.



Thanks![/font]

[/quote]

[font=“Tahoma”]Yes, I suspected as much. I was unable to test the add-on elsewhere, as everything is 2.2.3.



I wish there was a way to add a delay to the standard/default menu's in CS-Cart. (Categories)

As if you just go off the edge by a mm, the entire menu collapses, and disappears.



Would be great if we could combine this HIDE EMPTY CATEGORIES (and Sub-sub-sub-sub-categories) and make the Categories menu more user friendly by keeping the menu expanded… for a 500ms or 800ms delay…



[/font]

hi, is it possible to get the add-on to automatically hide empty categories AND to automatically unhide them?

in our case we have a multivendor platform and we cannot manually unhide former empty categories when a vendor puts the first product in it…

Addon to hide sold product after set period of time would be greatly apreciated :) just idea for next project…

I’ve tried this add-on a few times now, but each time all sorts of problems occur, categories etc. Sub-categories are still missed. Thank god everything is reverted when uninstalled.



Are there any planned updates Brandon? Or perhaps a $5 version which has been completed and tested in version 3.x?



Although, I’m sure I’ve seen another add-on that is available that does the same thing - hide empty categories, or is it just another of Brandons’? :confused:





So I guess these are the only two versions?



[attachment=5663:CS-Cart v2.x - Hide Empty Categories v1 (brandonvd) 2011.01.26.zip]



[attachment=5664:CS-Cart v2.x - Hide Empty Categories v2 (brandonvd) 2011.07.17.zip]

[size=2]> Updated …/func.php[/size]

CS-Cart v2.x - Hide Empty Categories v1 (brandonvd) 2011.01.26.zip

CS-Cart v2.x - Hide Empty Categories v2 (brandonvd) 2011.07.17.zip

any of you know if this works under csc 3.0.2 ??

No, I have no plans to update this addon. If anyone is interested, tbirnseth (Tony) created this addon for me, so if you want it updated, I'd recommend contacting him.



I no longer have use of this addon, so I don't need it upgraded and don't want to pay to upgrade it, sorry.



Thanks,



Brandon