Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Hiding entire categories


Dagster

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.

Link to comment
Share on other sites

  • 2 weeks later...

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

Link to comment
Share on other sites

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

Link to comment
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

 

Link to comment
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. 

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

Get the latest versions of my addons

Recommended SEO Addons

Link to comment
Share on other sites

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.

Link to comment
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

Link to comment
Share on other sites

@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. 😉

 

Link to comment
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.

 

Link to comment
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");

Link to comment
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

 

Link to comment
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");

 

Link to comment
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

Link to comment
Share on other sites

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"

Link to comment
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");

 

Link to comment
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

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...