Hide Empty Categories in Content Module List

  • Posts: 75
  • Thank you received: 7
  • Hikashop Business
2 years 2 months ago #339224

-- HikaShop version -- : 4.4.5
-- Joomla version -- : 3.10.3
-- PHP version -- : 7.4.27
-- Browser(s) name and version -- : 96.0.3

I have a Hikashop Content Module set to list view and category content type.

Is there a way to have only categories with products in it show in the list?

I have the "Only with products" setting set to 'Yes' under the Category data display section, but it does not seem to work. Right now every category shows regardless if there is nothing in it.

The caveat: We have many, many customers separated by access level who only see the products that are set to their access level.

So technically every category does have something in it, but only some can actually see it if it set to their access level. So some customers are becoming agitated that they have a full menu with nothing but (apparently) empty links.

With or without the content module, is there a way to get the functionality I want?

Please Log in or Create an account to join the conversation.

  • Posts: 81540
  • Thank you received: 13069
  • MODERATOR
2 years 2 months ago #339231

Hi,

The "Only with products" indeed doesn't take into account the user groups restrictions on the products.

That's something we can add and I think it's a good idea to add it.

For that, try to replace the code:

$additional_condition = $config->get('show_out_of_stock', 1) ? '' : ' AND p.product_quantity != 0';
by:
					$filters = array();
					if(!$config->get('show_out_of_stock', 1)) {
						$filters[] = 'p.product_quantity != 0';
					}
					$additional_condition = '';
					hikashop_addACLFilters($filters, 'product_access', 'p');
					if(count($filters))
						$additional_condition = ' AND ' . implode(' AND ', $filters);
in the file components/com_hikashop/views/category/view.html.php and that should hopefully do it.
Let us know how it goes. If it works fine, we can add that on our end for the next version of HikaShop so that you won't have to redo the change on each update of HikaShop.

The following user(s) said Thank You: wildweststudios

Please Log in or Create an account to join the conversation.

  • Posts: 75
  • Thank you received: 7
  • Hikashop Business
2 years 2 months ago #339242

It worked like a charm!

I logged in and out of many different clients and can confirm it only shows the category links when products exist in the category and are set to that client's user group.

Awesome, just what I needed. Thanks!

The following user(s) said Thank You: nicolas

Please Log in or Create an account to join the conversation.

Time to create page: 0.059 seconds
Powered by Kunena Forum