Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Enable/Disable categories contribution


tlelliott77

Recommended Posts

I can't find an ongoing thread for the Enable/Disable categories contribution so this is in a new thread.

 

I noticed that when you disable a subcategory the product count in the categories infobox still displays the total number of products as if the subcategory were enabled. To correct this you can change the following:

 

Find (line 378 in the version in the contribution):

      $products_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = p2c.products_id and p.products_status = '1' and p2c.categories_id = '" . (int)$category_id . "'");

And change to:

      $products_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS . " p, " . TABLE_CATEGORIES . " c, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and c.categories_status = '1' and p.products_status = '1' and p2c.categories_id = '" . (int)$category_id . "'");

 

If anyone knows of a suitable thread to add this to please post a reply so I can repost elsewhere.

 

Tim

Link to comment
Share on other sites

  • Replies 150
  • Created
  • Last Reply

Top Posters In This Topic

Hey Tim, thanks for the correction, but what file is that in?  Is it the /includes/functions/general.php file?

 

As for a suitable thread, I think you just started one for this Contribution.

 

Yes, the file is catalog/includes/functions/general.php.

 

p.s. Thanks to all who've contributed to this useful mod.

Link to comment
Share on other sites

  • 3 weeks later...

I have a problem now since I added this contribution. When you view New Products, it shows ALL products in ALL categories. Even products that you copy (by link) to other categories, causing them to be listed more than once.

 

I have 135 items right now and New Products show 314 items. Go to http://www.popthetop.com/catalog/products_new.php to see what I mean.

 

Here is the code that this contribution modified in products_new.php

//################## Added Enable / Disable Categories #################"
//  $products_new_query_raw = "select p.products_id, pd.products_name, p.products_image, p.products_price, p.products_tax_class_id, p.products_date_added, m.manufacturers_name from " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on (p.manufacturers_id = m.manufacturers_id), " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' order by p.products_date_added DESC, pd.products_name";

 $products_new_query_raw = "select p.products_id, pd.products_name, p.products_image, p.products_price, p.products_tax_class_id, p.products_date_added, m.manufacturers_name from " . TABLE_PRODUCTS . " p, " . TABLE_CATEGORIES . " c, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c left join " . TABLE_MANUFACTURERS . " m on (p.manufacturers_id = m.manufacturers_id), " . TABLE_PRODUCTS_DESCRIPTION . " pd where c.categories_status=1 and p.products_id = p2c.products_id and c.categories_id = p2c.categories_id and p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' order by p.products_date_added DESC, pd.products_name";
//################## End Added Enable / Disable Categories #################

 

Any ideas?

L8r,

PopTheTop

 

Published osC Contributions:

- eCheck Payment Module v3.1

- Reviews in Product Display v2.0

- Fancier Invoice & Packingslip v6.1

- Admin Notes / Customer Notes v2.2

- Customer Zip & State Validation v2.2

- Search Box with Dropdown Category Menu v1.0

 

Pop your camper's top today!

It's a popup thing...

You wouldn't understand

Link to comment
Share on other sites

You have to disable the products too

L8r,

PopTheTop

 

Published osC Contributions:

- eCheck Payment Module v3.1

- Reviews in Product Display v2.0

- Fancier Invoice & Packingslip v6.1

- Admin Notes / Customer Notes v2.2

- Customer Zip & State Validation v2.2

- Search Box with Dropdown Category Menu v1.0

 

Pop your camper's top today!

It's a popup thing...

You wouldn't understand

Link to comment
Share on other sites

  • 2 weeks later...

I have a problem now since I added this contribution. When you view New Products, it shows ALL products in ALL categories. Even products that you copy (by link) to other categories, causing them to be listed more than once.

 

I have 135 items right now and New Products show 314 items. Go to http://www.popthetop.com/catalog/products_new.php to see what I mean.

 

Here is the code that this contribution modified in products_new.php

//################## Added Enable / Disable Categories #################"
// ?$products_new_query_raw = "select p.products_id, pd.products_name, p.products_image, p.products_price, p.products_tax_class_id, p.products_date_added, m.manufacturers_name from " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on (p.manufacturers_id = m.manufacturers_id), " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' order by p.products_date_added DESC, pd.products_name";

?$products_new_query_raw = "select p.products_id, pd.products_name, p.products_image, p.products_price, p.products_tax_class_id, p.products_date_added, m.manufacturers_name from " . TABLE_PRODUCTS . " p, " . TABLE_CATEGORIES . " c, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c left join " . TABLE_MANUFACTURERS . " m on (p.manufacturers_id = m.manufacturers_id), " . TABLE_PRODUCTS_DESCRIPTION . " pd where c.categories_status=1 and p.products_id = p2c.products_id and c.categories_id = p2c.categories_id and p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' order by p.products_date_added DESC, pd.products_name";
//################## End Added Enable / Disable Categories #################

 

 

Does any one have any idea on how to fix this?

L8r,

PopTheTop

 

Published osC Contributions:

- eCheck Payment Module v3.1

- Reviews in Product Display v2.0

- Fancier Invoice & Packingslip v6.1

- Admin Notes / Customer Notes v2.2

- Customer Zip & State Validation v2.2

- Search Box with Dropdown Category Menu v1.0

 

Pop your camper's top today!

It's a popup thing...

You wouldn't understand

Link to comment
Share on other sites

  • 2 weeks later...

I noticed something strangely when i disabled something inside a category, such as a product or subcategory. Then disabled the entire category and enabled it again.

Everything inside the category was also enabled?

 

That seems a dodgy? :blink:

//Maz

Link to comment
Share on other sites

When you create a new category, it defaults to disable. How do you bring it to default as enabled?

L8r,

PopTheTop

 

Published osC Contributions:

- eCheck Payment Module v3.1

- Reviews in Product Display v2.0

- Fancier Invoice & Packingslip v6.1

- Admin Notes / Customer Notes v2.2

- Customer Zip & State Validation v2.2

- Search Box with Dropdown Category Menu v1.0

 

Pop your camper's top today!

It's a popup thing...

You wouldn't understand

Link to comment
Share on other sites

  • 1 month later...
Hi

if i disable a category i can still se products from that category in bestsellers and in reviews

 

Hi,

 

I'm having the same problem! Did you get it working? If so, Would you share the solution!

 

Thx in advance

 

/Charles

Link to comment
Share on other sites

No, still need a solution on that one.

L8r,

PopTheTop

 

Published osC Contributions:

- eCheck Payment Module v3.1

- Reviews in Product Display v2.0

- Fancier Invoice & Packingslip v6.1

- Admin Notes / Customer Notes v2.2

- Customer Zip & State Validation v2.2

- Search Box with Dropdown Category Menu v1.0

 

Pop your camper's top today!

It's a popup thing...

You wouldn't understand

Link to comment
Share on other sites

Anyone have a clue where I found the code changes to prevent disabled categories from showing the the categories navigation?

I had it all working and then due to case of HUA got things messed up and now I can't remember where I originally found the code changes.

Link to comment
Share on other sites

I found my problem, or at least a working solution to it.

In order to hide the disabled categories in the category box, I changed the line following

if ($category_depth == 'nested') {

of my index.php file from:

    $category_query = tep_db_query("select cd.categories_name, c.categories_image from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_id = '" . (int)$current_category_id . "' and cd.categories_id = '" . (int)$current_category_id . "' and cd.language_id = '" . (int)$languages_id . "'");

to this:

    $category_query = tep_db_query("select cd.categories_name, cd.categories_heading_title, c.category_head_title_tag, c.category_head_desc_tag, cd.categories_description, c.category_head_keywords_tag, c.categories_image from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_status = '1' and c.categories_id = '" . $current_category_id . "' and cd.categories_id = '" . $current_category_id . "' and cd.language_id = '" . $languages_id . "'");
$category = tep_db_fetch_array($category_query);

 

I'm not sure how I had it working before as this line is not changed in the index.php included with my downloaded contrib .zip.

Oh well...one of the great mysteries of the universe.

Hope this helps someone else.

Great contibution. I absolutely love it.

Link to comment
Share on other sites

  • 2 weeks later...
I have a problem now since I added this contribution. When you view New Products, it shows ALL products in ALL categories. Even products that you copy (by link) to other categories, causing them to be listed more than once.

 

I have 135 items right now and New Products show 314 items. Go to http://www.popthetop.com/catalog/products_new.php to see what I mean.

 

I found the solution by using a "distinct" for the SQL command. Here are the changes to do in products_new.php :

 

Change in the beginning of the file :

 

$products_new_query_raw = "select p.products_id...

 

to

 

$products_new_query_raw = "select distinct p.products_id,...

 

Second modification to have the SQL command to work :

 

Just below the SQL command, change

 

$products_new_split = new splitPageResults($products_new_query_raw, MAX_DISPLAY_PRODUCTS_NEW);

 

into

 

$products_new_split = new splitPageResults($products_new_query_raw, MAX_DISPLAY_PRODUCTS_NEW, 'p.products_id');

 

You will now have the exact number of all products and no duplicates anymore. There is maybe a better way by tweaking the SQL command but the "new products" page is not a critical page so my modification should be fine.

 

I will publish a new version of Enable/Disable categories 1.6 once I have finished my development. I did some other changes too like always :thumbsup:

 

Didier.

Link to comment
Share on other sites

Thanks, that worked like a charm!

L8r,

PopTheTop

 

Published osC Contributions:

- eCheck Payment Module v3.1

- Reviews in Product Display v2.0

- Fancier Invoice & Packingslip v6.1

- Admin Notes / Customer Notes v2.2

- Customer Zip & State Validation v2.2

- Search Box with Dropdown Category Menu v1.0

 

Pop your camper's top today!

It's a popup thing...

You wouldn't understand

Link to comment
Share on other sites

I noticed something strangely when i disabled something inside a category, such as a product or subcategory. Then disabled the entire category and enabled it again.

Everything inside the category was also enabled?

 

That seems a dodgy?  :blink:

 

Good point ! When changing the status of a main category, it changes the status for all subcatgories. So you loose it's original value.

 

Another way would have been NOT to touch the subcategories, but only changing the main category. It would have been more expensive in the frontend because you had to go up to the main category level to see if it's disabled or not. So it's maybe better to change the sub categories also.

 

To solve your problem, we should add a second column in the table "categories" to store the old value.

 

But we'll keep it manually. I will add it in the readme.txt as a limitation when I will publish a new version.

 

Didier.

Link to comment
Share on other sites

When you create a new category, it defaults to disable. How do you bring it to default as enabled?

 

Hi Scott !

 

I want to keep it disabled as default. For you , there are 2 solutions :

 

1. sql : change the default value of the "categories_status" attribute in table "categories" : put it to "1" instead of "0"

 

2. add the input field in the category page when you create a new one (like for products). This is my code of my categories.php page :

 

<tr>
           <td class="main"><?php echo TEXT_CATEGORY_STATUS; ?></td>
           <td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . tep_draw_radio_field('categories_status', '1', $enabled) . ' ' . TEXT_CATEGORY_ENABLED . ' ' . tep_draw_radio_field('categories_status', '0', $disabled) . ' ' . TEXT_CATEGORY_DISABLED; ?></td>
       </tr>

 

You have to put this where you want to display or modify a new category.

 

Also, add text defines for TEXT_CATEGORY_STATUS, TEXT_CATEGORY_ENABLED and TEXT_CATEGORY_DISABLED.

 

We need also to define $enabled and $disabled :

 

// DDB - 050409 - Enable & Disable Category
if (!isset($cInfo->categories_status)) $cInfo->categories_status = '1';
   switch ($cInfo->categories_status) {
     case '0': $enabled = false; $disabled = true; break;
     case '1':
     default: $enabled = true; $disabled = false;    
}

 

I'm unable to tell you where to put it but I think you get the idea of this code.

 

Didier.

Link to comment
Share on other sites

Has anyone used the Enable/Disable Categories contribution with the Main Categories contribution?

 

I just installed Enable/Disable Categories and everything is working well... but I need some help with modifying the Main Categories contrib so it also works with Enable/Disable. I'm no programmer so any pointers or help with this will be greatly appreciated.

 

Thanks in advance.

Paul

Link to comment
Share on other sites

Hi Scott !

 

I want to keep it disabled as default.  For you , there are 2 solutions :

 

1. sql : change the default value of the "categories_status" attribute in table "categories" : put it to "1" instead of "0"

 

2. add the input field in the category page when you create a new one (like for products).  This is my code of my categories.php page :

 

<tr>
? ? ? ? ? ?<td class="main"><?php echo TEXT_CATEGORY_STATUS; ?></td>
? ? ? ? ? ?<td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . tep_draw_radio_field('categories_status', '1', $enabled) . ' ' . TEXT_CATEGORY_ENABLED . ' ' . tep_draw_radio_field('categories_status', '0', $disabled) . ' ' . TEXT_CATEGORY_DISABLED; ?></td>
? ? ? ?</tr>

 

You have to put this where you want to display or modify a new category.

 

Also, add text defines for TEXT_CATEGORY_STATUS, TEXT_CATEGORY_ENABLED and TEXT_CATEGORY_DISABLED.

 

We need also to define $enabled and $disabled :

 

// DDB - 050409 - Enable & Disable Category
if (!isset($cInfo->categories_status)) $cInfo->categories_status = '1';
? ?switch ($cInfo->categories_status) {
? ? ?case '0': $enabled = false; $disabled = true; break;
? ? ?case '1':
? ? ?default: $enabled = true; $disabled = false; ? ?
}

 

I'm unable to tell you where to put it but I think you get the idea of this code.

 

Didier.

 

 

 

Well, my database already has a 1 there so I do not need to change that.

 

This is what I have:

categories_status  / tinyint(1)  / UNSIGNED / No  / 1

L8r,

PopTheTop

 

Published osC Contributions:

- eCheck Payment Module v3.1

- Reviews in Product Display v2.0

- Fancier Invoice & Packingslip v6.1

- Admin Notes / Customer Notes v2.2

- Customer Zip & State Validation v2.2

- Search Box with Dropdown Category Menu v1.0

 

Pop your camper's top today!

It's a popup thing...

You wouldn't understand

Link to comment
Share on other sites

  • 1 month later...

I installed this contrib, and I don't know if it all works, because- when I change the categories box, the loading gets completely hung up. My browser just hangs fire until it tells me could not load any data. It hangs at the categories box.

The change is so simple; from

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

to

 ?$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.categories_status = '1' and c.parent_id = '0' and c.categories_id = cd.categories_id and cd.language_id='" . (int)$languages_id ."' order by sort_order, cd.categories_name");

I've tried it on several different boxes, and I get the same hangup each time. Any ideas?

Edited by Dragonmom

psst... wanna buy a wand?

Link to comment
Share on other sites

I installed this contrib, and I don't know if it all works, because- when I change the categories box, the loading gets completely hung up. My browser just hangs fire until it tells me could not load any data. It hangs at the categories box.

The change is so simple; from

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

to

  $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.categories_status = '1' and c.parent_id = '0' and c.categories_id = cd.categories_id and cd.language_id='" . (int)$languages_id ."' order by sort_order, cd.categories_name");

I've tried it on several different boxes, and I get the same hangup each time. Any ideas?

 

I believe your problem might be your second sql statement.

 

Try:

$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.categories_status = '1' and c.parent_id = '" . (int)$parent_id . "'  and c.categories_id = cd.categories_id and cd.language_id='" . (int)$languages_id ."' order by sort_order, cd.categories_name");

 

All I did is replace c.parent_id = '0' with c.parent_id = '" . (int)$parent_id . "'

 

Let me know how that works out for you.

Link to comment
Share on other sites

Well, it doesn't hangup anymore- I think I can only use it on a top category, but that's okay- I was planning to use it to create two different lists of my work- one the custom stuff, and one with currently made items as well. That way, I can disable the current listings when I take off with them to craft shows- so I don't come home to finds something has sold twice

:shudder- that's happened before!:

psst... wanna buy a wand?

Link to comment
Share on other sites

  • 1 month later...

I?m installing this contrib and found some "bugs" in it as described below, so I?m posting a fix for them (sorry for no time to make a new package):

 

- when you access the product page typing the url, you still can see the product information even if its category is disabeld. The fix for this is as follows:

 

in product_info.php change de the following line:

 

$product_check_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'");

 

to:

 

$product_check_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS . " p left join " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c on p.products_id = p2c.products_id left join " . TABLE_CATEGORIES . " c on p2c.categories_id = c.categories_id, " . TABLE_PRODUCTS_DESCRIPTION . "  pd where c.categories_status = '1' and p.products_status = '1' and p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'");

 

- the customer shouldn?t be able to see the name of the category nor product?s name, so you have to change the breadcrumb trail in application top:

 

find the line wich inserts the category?s name to the breadcrumb

 

$categories_query = tep_db_query("select categories_name from " . TABLE_CATEGORIES_DESCRIPTION . " where categories_id = '" . (int)$cPath_array[$i] . "' and language_id = '" . (int)$languages_id . "'");

 

and change it to:

 

$categories_query = tep_db_query("select categories_name from " . TABLE_CATEGORIES_DESCRIPTION . " cd left join " . TABLE_CATEGORIES . " c on cd.categories_id = c.categories_id where c.categories_status = '1' and cd.categories_id = '" . (int)$cPath_array[$i] . "' and language_id = '" . (int)$languages_id . "'");

 

find the line wich inserts the product?s name to the breadcrumb:

 

$name_query = tep_db_query("select pd.products_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and p.products_id = pd.products_id")

 

and change it to:

 

$name_query = tep_db_query("select pd.products_name from " . TABLE_PRODUCTS . " p left join " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c on p.products_id = p2c.products_id left join " . TABLE_CATEGORIES . " c on p2c.categories_id = c.categories_id, " . TABLE_PRODUCTS_DESCRIPTION . "  pd where c.categories_status = '1' and p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and p.products_id = pd.products_id")

 

and that will do it.

 

Thank?s for the contrib!

 

Claudio

Link to comment
Share on other sites

I?m installing this contrib and found some "bugs" in it as described below, so I?m posting a fix for them (sorry for no time to make a new package):

 

- when you access the product page typing the url, you still can see the product information even if its category is disabeld. The fix for this is as follows:

and that will do it.

 

Thank?s for the contrib!

 

Claudio

 

Hey clongato thanks for the updates. Could you please reply with the filenames for those fixes?

 

Thanks

Link to comment
Share on other sites

In version 1.6.1 the Application_top.php has an incorrect SQL Statement.

 

In Application_top.php find:

$model_query = tep_db_query("select pd.products_model from " . TABLE_PRODUCTS . " p left join " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c on p.products_id = p2c.products_id left join " . TABLE_CATEGORIES . " c on p2c.categories_id = c.categories_id, " . TABLE_PRODUCTS_DESCRIPTION . " pd where c.categories_status = '1' and p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and p.products_id = pd.products_id");

 

Replace with:

$model_query = tep_db_query("select p.products_model from " . TABLE_PRODUCTS . " p left join " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c on p.products_id = p2c.products_id left join " . TABLE_CATEGORIES . " c on p2c.categories_id = c.categories_id, " . TABLE_PRODUCTS_DESCRIPTION . " pd where c.categories_status = '1' and p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and p.products_id = pd.products_id");

 

Thats it,

Al

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...