Jump to content
Dagster

Hiding entire categories

Recommended Posts

Is it possible to hide a category from public display? I know you can set a product to be inactive and it doesn't show up,  but I would like to do the same sort of thing for the category itself and can't seem to find anything that might provide that capability.

I'm using v2.3.4.1, if that helps.

Share this post


Link to post
Share on other sites

Hi @raiwa I went to install this on v2.3.4.1 but the module does not seem to be compatible part of the install says
In catalog/index.php

Near 89 Find:

          $categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.categories_image, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '" . (int)$category_links[$i] . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' order by sort_order, cd.categories_name");

Replace With:

          $categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.categories_image, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '" . (int)$category_links[$i] . "' and c.categories_status = 1 and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' order by sort_order, cd.categories_name");

but the index.php only goes to line 78 and has no lines like this in it.

The install says
There may other instances I have missed, the general Rule is:
If there is a general tep_db_query including  TABLE_CATEGORIES add the filter:  and categories_status = 1

So where have these been moved to seems they are not in index.php

As I would also like to install this add_on

Share this post


Link to post
Share on other sites

I never used this Addon and can't help you. I just gave you the link where to find it.

Share this post


Link to post
Share on other sites
44 minutes ago, supercheaphobb said:

So where have these been moved to seems they are not in index.php 

Use a tool like grepWin  to search for them in your install. In stock frozen they are,

image.png.3a0296b826b36fb50a8c43a21132d5da.png


 

Share this post


Link to post
Share on other sites
42 minutes ago, supercheaphobb said:

So where have these been moved to seems they are not in index.php

Your version of oscommerce has parts of the index.php file in modules so you would have to find the code to change there. And even then, that addon is not coded for your version of oscommerce so there will be changed needed to make it compatible. It never was a simple install and converting it to work with your shop at the same time will be time-consuming, though it is possible. 

Share this post


Link to post
Share on other sites
Posted (edited)

I use this addon and have to say that it is very helpful but the installation is very complicated.

You have to rewrite all product queries. all modules for product display. all boxes for product display. then come the functions and a few other things that need to be adjusted and changed. Nevertheless, with a little patience, everything is possible.

Edited by YePix

Share this post


Link to post
Share on other sites

Sounds like this is a bit above my knowledge on what needs changing to what....

It's so hard to support OSC when so many of the needed add_ons are just way above what a shop owner can handle programming wise..

I will add this to my wish list with so many other items I have tried to setup

Share this post


Link to post
Share on other sites
Posted (edited)

@supercheaphobb

Hi, I think it may be not at all difficult to hide categories.

First, prefix the category name with something like "*", e.g. "Shoes" to "*Shoes".

Secondly, to make sure categories with "*" prefix not be shown upon queried, simply set the filter in categories database query.

 

Hmm.. just an idea.  Someone please write a contribution. It sounds simple but it is difficult for me because I am not a coder. 😉

 

Edited by kgtee

Share this post


Link to post
Share on other sites

Renaming Cat's is probably not a good idea as it will imapct your SEO for the site. Also hiding cat's will impact all products within that cat again not good for SEO I would think.

The code needed is already in osC as products can be turned off. They use "products_status" which can be set in admin to determin if a product should be shown or not. Just use the same code and add  new colum "categories_status" to categories table. Then simply add status code to categories in catogorys.php in admin so you can turn them on and off.

Then simply add the status to the cats db query as it is to products and every time cats are displayed they will be fillterd by status.

Personaly I dont like turning things off as it will affect search engines as links may be lost or broken. This artical covers some of the pros and cons.

https://www.goinflow.com/manage-stock-products-seo/

If it's out of stock better to show when new stock will be available, if it's no longer avaiable better to redirect to alternative product. If no alternative redirect to index.

SEO can become complex so best to get profesional help.


 

Share this post


Link to post
Share on other sites

Hi @JcMagpie looked at that one too and it again wont work on frozen, again it says to edit index.php
Once I get a couple of more urgent things resolved I will fork out for a programmer to get it working.

Step 6

======

In:  catalog/index.php

======================

 

Wherever you find a query that references TABLE_CATEGORIES add the "and status_categ = 1" in the query, so only active subcategories are selected from the database and displayed as icons in the main page. I found 6 places in the index.php where this must be done.

 

Around line 23 change the query to read:

 

    $category_parent_query = tep_db_query("select count(*) as total from " . TABLE_CATEGORIES . " where parent_id = '" . (int)$current_category_id . "' and status_categ = 1");

Share this post


Link to post
Share on other sites
1 hour ago, supercheaphobb said:

fork out for a programmer to get it working

Sure they can then test fully as required.

However just tested and works fine. Remember in frozen cat is now in a class so make change in that

public_html/includes/classes/category_tree.php

line 41

$categories_query = tep_db_query("select c.categories_id, c.parent_id, c.categories_image, cd.categories_name, cd.categories_description, cd.categories_seo_description, cd.categories_seo_keywords, cd.categories_seo_title from categories c, categories_description cd where c.categories_id = cd.categories_id and cd.language_id and c.status_categ = '1' = '" . (int)$languages_id. "' order by c.parent_id, c.sort_order, cd.categories_name");

Make sure to run SQL first so status_categ is in db or it will brake store front. But works fine

before

image.png.8f5dae0e44d955e38c18fb131c602732.png

after turning off first cat Hardware we have

image.png.122b983eb8c4d327bc94040e81f09675.png

db

image.png.fc5e424559e15a3e81e299dbb318396c.png


 

Share this post


Link to post
Share on other sites

that's exactly how addon works, who posted @raiwa above and described it.

Share this post


Link to post
Share on other sites

Ok well it's half way installed on my test site only stopped when I got stuck on index.php

I will go and have a plat now and see how I go

 

Share this post


Link to post
Share on other sites

look the file category_tree.php in includes/classes/
here the query must be supplemented by: " and c.categories_status = 1".

Share this post


Link to post
Share on other sites

like this

$categories_query = tep_db_query("select c.categories_id, c.parent_id, c.categories_image, cd.categories_name from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_id = cd.categories_id and c.categories_status = 1 and cd.language_id = '" . (int)$languages_id. "' order by c.parent_id, c.sort_order, cd.categories_name");

 

Share this post


Link to post
Share on other sites

Thank you @YePix you send that just as I got an error on the front page. I will post all the changes I had to make here to make it work when done for others

Share this post


Link to post
Share on other sites

First of all thank you to those that assisted and supplied the code I needed to get this to work

To get the add_on Hide Categories & Products  working in osCommerce Online Merchant v2.3.4.1 CE (Aka Frozen BS)

I opened the Hide Categories & Products V1.1.txt (install instructions) in my favorite text editor and did a search and replace as per below

Search $HTTP_GET_VARS
replace $_GET

Search $HTTP_POST_VARS
replace $_POST

Search DIR_WS_IMAGES
replace 'images/'

Search FILENAME_CATEGORIES
replace 'categories.php'

Then install as per instructions until you get to In catalog/index.php, instead go to catalog/includes/classes/category_tree.php

Find at line 41
	$categories_query = tep_db_query("select c.categories_id, c.parent_id, c.categories_image, cd.categories_name, cd.categories_description, cd.categories_seo_description, cd.categories_seo_keywords, cd.categories_seo_title from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id. "' order by c.parent_id, c.sort_order, cd.categories_name");

ands replace with
	$categories_query = tep_db_query("select c.categories_id, c.parent_id, c.categories_image, cd.categories_name from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_id = cd.categories_id and c.categories_status = 1 and cd.language_id = '" . (int)$languages_id. "' order by c.parent_id, c.sort_order, cd.categories_name");

and that's it

Share this post


Link to post
Share on other sites
Posted (edited)

Now I should point out that this will stop the category or sub category showing but if you have stock in the category that is still active it will not stop this item coming up in a search.
Which can or can not be helpful, If you want the products also not to show you will need to set them to inactive. If there is a lot of items in the category I choose to use "easy populate" to export then change the status and import (update) if only a small amount you can either do it manually or use "easy update"

Edited by supercheaphobb

Share this post


Link to post
Share on other sites

nice that it works but it's not all. you have to take a closer look at all modules and boxes otherwise products in the hidden category will continue to be displayed

Share this post


Link to post
Share on other sites
find

$categories_query = tep_db_query("select c.categories_id, c.parent_id, c.categories_image, cd.categories_name, cd.categories_description, cd.categories_seo_description, cd.categories_seo_keywords, cd.categories_seo_title from categories c, categories_description cd where c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id. "' order by c.parent_id, c.sort_order, cd.categories_name");


change to

$categories_query = tep_db_query("select c.categories_id, c.parent_id, c.categories_image, cd.categories_name, cd.categories_description, cd.categories_seo_description, cd.categories_seo_keywords, cd.categories_seo_title from categories c, categories_description cd where c.categories_id = cd.categories_id and c.categories_status = 1 and cd.language_id = '" . (int)$languages_id. "' order by c.parent_id, c.sort_order, cd.categories_name");

 

Share this post


Link to post
Share on other sites

I will leave that to the choice of the shop owner, having hidden items with a very unusual name might be good. I will just set the products inactive

@YePix If you install Responsive-osCommerce-2341-Frozen from github then it has the line I put up

$categories_query = tep_db_query("select c.categories_id, c.parent_id, c.categories_image, cd.categories_name, cd.categories_description, cd.categories_seo_description, cd.categories_seo_keywords, cd.categories_seo_title from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id. "' order by c.parent_id, c.sort_order, cd.categories_name");

not sure why you have different original code unless you have edge?
but the code you gave to replace it works so all good

Share this post


Link to post
Share on other sites
Posted (edited)

this line is from Frozen

if the seo is not queried there are errors in the issue

Edited by YePix

Share this post


Link to post
Share on other sites

Weird I even opened the zip file download 21-05-2019 and it has my version. Oh well it's what it gets replaced with that important 😉

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×