Jump to content
Sign in to follow this  
spooks

Contribution: Hide Categories & Products

Recommended Posts

Hide Categories & Products

 

This is a simple contribution to allow you to hide, disable or inhibit any category & optionally all products within that.

 

I created this a while back but never a support thread, so I'm doing that now.

 

I searched for a solution for this, solutions I found were either over complex, or poorly done, so this is my solution.

 

I believe in keeping things as simple as possible & not re-inventing the wheel.

OSC already has functions to hide any product, so I use that for products.

This adds a new entry in the category table (categories_status) so all thats needed on the client side is to add a filter to sql queries ( and categories_status = 1 ).

This does not allow for per-customer filtering, although I reckon it wouldent be too difficult to add.

 

Most changes occur in admin/categories.php. These allow you to change the status of any category & the status of all products within a category.

 

Contribution is at http://addons.oscommerce.com/info/5907


Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Share this post


Link to post
Share on other sites
Just one quick question, I have installed this, it was easy to follow and works great thanks, but I wondered if it is possible to link the turning off of the products with the turning off of the categories, so that you only have to set the category inactive and the products are automatically set inactive?

 

I`m not sure thats a good idea, if someone has a lot of product in a category with a mixture of disabled/enabled that one click could make them tear their hair out!!

After all you only need to select 'edit' category then its just two clicks to do the same.

 

Actually that leads me to a second question, is it possible to set a category inactive and all sub-categories are set inactive?

 

Thats possible, though a little more compex than may appear, I`ll take a look when I've time.

Edited by spooks

Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Share this post


Link to post
Share on other sites

Thanks Sam,

 

After all you only need to select 'edit' category then its just two clicks to do the same.
lol, I guess its just me being lazy ;)

 

Anyway, its certainly an improvement on the 'other version' and much easier to install!

 

Keep up the good work!

 

Dave

Share this post


Link to post
Share on other sites

What you could do is replace (47):

 

tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $HTTP_GET_VARS['cPath'] . '&cID=' . $HTTP_GET_VARS['cID']));

 

with:

 

tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $HTTP_GET_VARS['cPath'] . '&cID=' . $HTTP_GET_VARS['cID'] . '&action=edit_category'));

 

that would put you strait in edit mode after change a category status


Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Share this post


Link to post
Share on other sites

I have made the file changes, uploaded files including images, and successfully run the database query, and all appears well in admin. I can click green/red icons. Only thing is, it does not hide categories. Have I missed something?

Share this post


Link to post
Share on other sites
I have made the file changes, uploaded files including images, and successfully run the database query, and all appears well in admin. I can click green/red icons. Only thing is, it does not hide categories. Have I missed something?

 

I'm having the same problem. Looking in the database, the categories_status on an inactive category is correctly set to "0", but it's still showing up in the navigation. Here's the relevant code:

 

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

 

You can see the filter - "categories_status = 1" - so it should be ignoring categories_status = 0, right?

 

Anyone got any ideas?

Edited by rebelina

Share this post


Link to post
Share on other sites

Found out what was wrong in my case. I'm not using boxes/categories.php anymore as I installed a different categories menu some time ago - I should have been editing ul_categories instead. So if you're having this problem, remember to check you're editing the right file for your shop

Share this post


Link to post
Share on other sites

Hi

 

Just found this thread because I am looking to do what Stubbsy (2nd post in) wants to do about having the category hidden when products inside are hidden but display the category if one or more items in that category is marked "in stock".

 

I understand Spooks's answer and it's a great contrib so lets hope Spooks or whoever can add this when they have time

 

 

Many thanks

 

Ian

Share this post


Link to post
Share on other sites

Hi

 

Just found this thread because I am looking to do what Stubbsy (2nd post in) wants to do about having the category hidden when products inside are hidden but display the category if one or more items in that category is marked "in stock".

 

I understand Spooks's answer and it's a great contrib so lets hope Spooks or whoever can add this when they have time

 

 

Many thanks

 

Ian

 

 

Its feasable, but there r a lot of provisows that would need to be considered, ie if a category is disabled is it ok/or not to enable on status change of a product, should status change on client side or not when product staus changes since it went out of stock, ......

 

 

Its something I'll look at in time, but its on the backburner for now!! smile.gif


Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Share this post


Link to post
Share on other sites

Its feasable, but there r a lot of provisows that would need to be considered, ie if a category is disabled is it ok/or not to enable on status change of a product, should status change on client side or not when product staus changes since it went out of stock, ......

 

 

Its something I'll look at in time, but its on the backburner for now!! smile.gif

 

Hi Sam

 

Thanks for the reply. I can't remember why I wanted the "extra bit" adding because I was looking at it today and testing and it works great

 

Cheers

 

Ian

Share this post


Link to post
Share on other sites

Anyone know how to do this:

I have a cat that i have set to inactive as i have the link in the nav bar to that page, but then i need the sub-cats still working ?

These are not being shown any idea how to get this to work ?

Share this post


Link to post
Share on other sites

Anyone know how to do this:

I have a cat that i have set to inactive as i have the link in the nav bar to that page, but then i need the sub-cats still working ?

These are not being shown any idea how to get this to work ?

 

 

you just need to alter the sql a bit, look at that.


Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Share this post


Link to post
Share on other sites
ALTER TABLE `categories` ADD `categories_status` INT( 1 ) NOT NULL DEFAULT '1';

ALTER TABLE `categories` CHANGE `categories_status` `categories_status` INT( 1 ) NOT NULL DEFAULT '0' ;

 

I have no idea what or how to change sql, could you help me please ?

Share this post


Link to post
Share on other sites

I have no idea what or how to change sql, could you help me please ?

 

 

without knowing which precise page your talking of, and possibly part of that page, I've no idea which sql would need modifying.

 

 

when your trying to change something you must be very specific in your query, otherwise people don't know what u mean so ignore you. smile.gif


Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Share this post


Link to post
Share on other sites

I would like the sub-cats to show on this page:

http://kjexotics.co.uk/euro/livestock-c-21.html'>http://kjexotics.co.uk/euro/livestock-c-21.html

 

If you go to the home page:

http://kjexotics.co.uk/euro

You can see i have disabled this cat and placed it in the nav bar (but i need the sub-cats to show).

Any more questions just ask (sorry i just didnt want my pages indexed by search engines) ?

 

Plus i am trying to get rid of the gap on the left if you know how to do that?

I have this code so far (i want the left to stay on every other page part from in this cat (21))

<td class="left-column" width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2">

<!-- left_navigation //--><?php

if ($current_category_id != 21) require(DIR_WS_INCLUDES . 'column_left.php');

?>

<!-- left_navigation_eof //-->

</table></td>

Share this post


Link to post
Share on other sites

Does anyone know how to change this ? Do you need more infomation (if so just ask).

Thanks for any help.

Share this post


Link to post
Share on other sites

 

 

 

 

Having looked at this, it should work fine as is, all the contrib dose is disable individual categories just because a category parent is disabled will not stop its subs from appearing, just call the parent manually, as you have, check though that subs exist, are enabled & have product. wink.gif

 

Please do not post unrelated questions in existing threads (hijacking).


Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Share this post


Link to post
Share on other sites

Hi Sam

Ive installed this contribution and it works fab.

 

I was wondering if you knew where i could get code to change the hidden category to keep all products active but hide them from the public but still active for purchasing.

 

The reason why is im installing ollacart for my high street shop to link to my website inventory, my problem is getting photos in time to upload on the web the same time as it comes into the shop, i need the products active for the POS but i don't want products visible on the web that are not finished with images.

 

Any ideas?

 

Thanks

 

Emma

Share this post


Link to post
Share on other sites

 

I was wondering if you knew where i could get code to change the hidden category to keep all products active but hide them from the public but still active for purchasing.

 

 

 

Thats the way it works, if you disable a category, only that is done, you have to set within that if you also want to disable all products within.

 

 

ie if you search for a product thats in a hidden category, it will be found, unless you modify the search to check category too. wink.gif


Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Share this post


Link to post
Share on other sites

Hi,

 

If anyone is having a problem with this contribution when used with Categories Image Box contribution, then please see the following fix by Kymation:

 

In catalog/includes/modules/categories_images.php find (near line 26)

 

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

 

and replace with:

 

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

 

This will hide the category from the categories image box as well.

 

All credit to Kymation for this fix.

 

Thanks


Now running on a fully modded, Mobile Friendly 2.3.4 Store with the Excellent MTS installed - See my profile for the mods installed ..... So much thanks for all the help given along the way by forum members.

Share this post


Link to post
Share on other sites

Hello Sam.

I have installed your contribution but I do not have the catalog/boxes/categories.php - file? In fact I do not have a catalog/boxes - in os 2.3.1.

The contribution is up and I can select inactive, but it still shows the categories on the menu in the box. I can select the items in the category and make them inactive, so as a temporary fix I took off the titles and put them in sort order 20 and 21 - this puts black space at the bottom of box. Would you please help. Perhaps it is that I do not have the additional page to edit that is causing the problem. Is there somewhere else I can look?

Your help is appreciated.

here is my site/ be warned it is an adult site: couplescorner.biz

 

Jenny

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
Sign in to follow this  

×