Hi,
Well, there are several ways to go about it:
1. You could simply use the products listing features:
- use the left explorer to access the category of the products you want to not be available
- change the pagination settings to have all the products of the category on one page
- use the checkbox at the top to select all the products
- click on the unpublish button at the top and all the products of that category will be unpublished at once
And when a product is unpublished, its page won't be available and it will even be removed from the cart if someone already has it in his cart and is trying to go through the checkout. It's even better than the code solution provided by Jerome 7 years ago because this would only remove the products from the listing, and wouldn't prevent the users from accessing directly the product page.
2. Another approach would be to create a mass actions of the data type "category" via the menu System>Mass actions. The published mass action would have:
- a trigger "after a category is updated"
- an action "run MySQL query with the query:
UPDATE #__hikashop_product AS p SET p.product_published = {category_published} WHERE p.product_id IN (SELECT product_id FROM #__hikashop_product_category WHERE category_id = {category_id});
That way, when you would publish/unpublish a category, it would automatically publish/unpublish the corresponding products
3. A cleaner approach would be to develop a plugin which would use the many events in HikaShop to automatically cancel the display of a product page etc after checking the categories. But that's a lot more difficult to do. The advantage of this method, is that you would keep the published state of each product the way it is set in the backend. Because with the previous two methods, unpublished products would be automatically published when you want to reenable a category and vice-versa even if you have products you don't want to change.