Addon or mod to hide empty categories

I’m running a site right now that has over 11,000 products and tons of categories. I update my stock every couple of days.



I would like to have an addon or mod coded that would hide my categories that either don’t have products or have products in them that are out of stock.



What would be ideal is to have something work on my imports or a php script or something to run after my imports. Basically it would check the stock levels of the products in each category and hide or activate the category as needed.



Does any of this make any sense to you guys?



I’d need this coded to work with 2.1.2.



If you could please pm me your thoughts and what you would charge, I’d really appreciate it.



Thank you,



Brandon

Ive sen afew threads about thi sBrandon but nonw have any solution, if you work it out It will be good benefit.



John

Have you tried the checkbox for “Show out of stock products” under Admin/Settings/ Catalog?

I’m assuming this might not work since it doesn’t hide the entire category. Don’t know how many products you have in a category. Just a thought.

No, that won’t work. It does hide the products, but the categories are still there. When a customer clicks on that category, it just says there are no products.



I want something that will just hide the category so people don’t waste their time just clicking around in categories that don’t have products.



Thanks for the idea though.



Brandon

you could do it, but it would be a performance issue because you’d have to have it count the number of visible products in every category every time a page loaded.



and caching wouldn’t necessarily help because it would have to either test against the database for new products and compare to cache, or not show any new products / categories until the cache expired.



if you don’t have a lot of categories, or don’t have a lot of products, then it’s very possible.

[quote]

you’d have to have it count the number of visible products in every category every time a page loaded.

[/quote]



That would be a poor design choice. A utility should be run that would capture those categories that are “empty” (by Brandon’s definition) and then utilize the hook for get_categories to not return those categories. It would all be the same SQL statement then.

I agree, however that doesn’t allow him to add products to those categories in real-time, he’d have to run the utility every time a product was added to an empty category… which is a feasible option. though I disagree with the same sql statement… it would be more efficient to have a table that has the “empty” categories in, and then select from the category table, joining the “blank” table and only show the ones that aren’t in the blank table…

[quote]

it would be more efficient to have a table that has the “empty” categories in, and then select from the category table, joining the “blank” table and only show the ones that aren’t in the blank table…

[/quote]

Absolutely correct and it becomes one squ statment using the get_categories hook when the system retrieves categories.

I just posted this addon over at:



[url]http://forum.cs-cart.com/showthread.php?t=22629[/url]



Brandon