Jump to content

Archived

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

veego

Hide Categories with category cache

Recommended Posts

Hi Everyone,

 

Since author didn't create a support thread for this great add-on, so lets create one and discuss any problems on installation and help others to solve the problem.

 

I found that this add-on should be the upgrade from old add-on "Activate or inactivate category of catalog" and the last update of that add-on still be in used on "Hide Categories with category cache".

 

please see below from user ssnb on 29 Jan, 2010

 

There is an error in the following code

 

 

Step 6

======

 

In: catalog/index.php

 

 

Here's the original code contained in the instructions: In the replacement code (block 2 below) it includes a reference to "p.products_msrp" - I assume that's a piece of code from another contribution.

 

This broke my site, but when I removed all references to that code, it all worked fine.

So if you get an error relating to that piece of code, just go ahead and remove "p.products_msrp," from the replacement code block below.

 

Just thought I'd add this in case anyone has the same issue!

 

Attachment file is the same as this

 

 

++++++++++++++++++++++++++++++++++++

 

Step 6

======

 

In: catalog/index.php

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

---------------------------------

Just below this find this section of code:

 

// We are asked to show only a specific category

$listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_status = '1' and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$HTTP_GET_VARS['filter_id'] . "'";

} else {

// We show them all

$listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m where p.products_status = '1' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "' and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "'";

}

} else {

// show the products in a given categorie

if (isset($HTTP_GET_VARS['filter_id']) && tep_not_null($HTTP_GET_VARS['filter_id'])) {

// We are asked to show only specific catgeory

$listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_status = '1' and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . (int)$HTTP_GET_VARS['filter_id'] . "' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$current_category_id . "'";

} else {

// We show them all

$listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_status = '1' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$current_category_id . "'";

 

and REPLACE it with the following:

 

// We are asked to show only a specific category

$listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_msrp, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_status = '1' and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$HTTP_GET_VARS['filter_id'] . "'";

} else {

// We show them all

$listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_msrp, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . $ptoc . TABLE_MANUFACTURERS . " m where p.products_status = '1' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "' and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "'" . ($ptoc != '' ? ' and p.products_id = p2c.products_id ' : '');

}

} else {

// show the products in a given category

if (isset($HTTP_GET_VARS['filter_id']) && tep_not_null($HTTP_GET_VARS['filter_id'])) {

// We are asked to show only specific manufacturer

$listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_msrp, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_status = '1' and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . (int)$HTTP_GET_VARS['filter_id'] . "' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$current_category_id . "'";

} else {

// We show them all

$listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_msrp, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_status = '1' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$current_category_id . "'";

}

}

$listing_sql .= $hiddenlist;

Share this post


Link to post
Share on other sites

from a glance, check your closing brackets if you get a parse error, the code above has you replacing code without also replacing your closing brackets, there should be two closing brackets and if you were following the instructions as written you would now have four, causing an error.

Share this post


Link to post
Share on other sites

Hi,

 

I have a problem on this module, I finished install the latest update on Oct, 2014. After installed, I can hide or show the categories and its subcategories with no problem. But I can't hide the products from a hidden categories.

 

I know there is a setting call Hide Hidden Category Products on Admin panel -> My Store, and i was set to True, but still can't hide the products from the hidden category.

 

Does anyone have the same problem?!

 

Please advised.

 

Veego

Share this post


Link to post
Share on other sites

This contribution appears to be missing

 

/includes/cache/category_cache.php

 

It is not in any of the packages for this contribution, hopefully we can get a complete package including this file uploaded.

 

Cheers

 

G

 

@@wdepot


Need help installing add ons/contributions, cleaning a hacked site or a bespoke development, check my profile

 

Virus Threat Scanner

My Contributions

Basic install answers.

Click here for Contributions / Add Ons.

UK your site.

Site Move.

Basic design info.

 

For links mentioned in old answers that are no longer here follow this link Useful Threads.

 

If this post was useful, click the Like This button over there ======>>>>>.

Share this post


Link to post
Share on other sites

/includes/cache/category_cache.php is automatically generated. Whenever you edit a category and save the change a new category_cache.php file is generated. To create the file for the first time simply edit a category and then save, no actual change necessary.

Share this post


Link to post
Share on other sites

Thanks, it just took several screens containing error messages before the file was created and they went away.

 

failed to open stream: No such file or directory

Headers already sent

 

Cheers

 

G


Need help installing add ons/contributions, cleaning a hacked site or a bespoke development, check my profile

 

Virus Threat Scanner

My Contributions

Basic install answers.

Click here for Contributions / Add Ons.

UK your site.

Site Move.

Basic design info.

 

For links mentioned in old answers that are no longer here follow this link Useful Threads.

 

If this post was useful, click the Like This button over there ======>>>>>.

Share this post


Link to post
Share on other sites

Hello!

 

I wonder, if it is possible to disable categories caching in this add-on?

My guess is that w/o cahing things are more bulletproof:)

 

Or, may be, I an afraid of unexisting problems and disabling cache is not necessary?

Share this post


Link to post
Share on other sites

Disabling the cache is not necessary and will only result in more queries to the database to generate each web page which is slower than including one PHP file. Our site uses a large number of categories (currently 383) that are nested fairly deep. By using the category cache we eliminated over 200 database queries per web page! If we showed category counts it would have eliminatated a lot more than that. Just be sure to generate a new cache file as soon as you install the admin side of the contribution by editing and saving a category (no change actually necessary) and the cache will be ready to use. The contribution is designed to regenerate the cache file from the database any time a change is made to a category. If you use product counts the cache will be regenerated any time a product is added, deleted or undergoes a status change. Also if you use product counts each category is counted only once with the totals added to parent categories. Standard osCommerce will count products in nested categories multiple times which can greatly slow down a web site.

Share this post


Link to post
Share on other sites

OK, thanks a lot! Will try to install it:) I am migrating now from 2.2 to 2.3.4 BS......

 

By the way, what kind of categories box are you using with THAT big number of categories? And what is the average length of categories names?

 

Many tnks for you input!

Rgds,

Vladimir

Share this post


Link to post
Share on other sites

We use the enhanced categories box included with the contribution. I'm not sure about the average length of the category names but we do have some that use the maximum 64 characters that the database allows. Our category_cache.php is still only 134KB if that is what you are worried about.

Share this post


Link to post
Share on other sites

hi how to add these codes into this bm_categories.php file (https://github.com/gburton/Responsive-osCommerce/blob/master/includes/modules/boxes/bm_categories.php)

 

In catalog/includes/modules/boxes/bm_categories.php

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

 

Find: (around line 87:)

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

 

after: " cd where c.parent_id = '0'

Add this: and c.status_categ = '1'

 

Result:

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

 

----------------------------------------

 

 

FIND: (around line: 112)

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

 

after: " cd where c.parent_id = '" . (int)$value . "'

Add this:  and c.status_categ = '1'

 

Result:

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

 

---------------------------------------------

Share this post


Link to post
Share on other sites

Hi All,

 

Did anyone installed and work on Modular Front Page 1.4?! I had this module installed which will replace the original front page,

this module has a file called fp_new_product.php which will replace the original index.php to handle the front page.

 

Unfortunately, hide categories with category cache does not included any code for Modular Front Page.

 

My problem is 

When I finished installing Hide categories with category cache, everything seem work fine except the front page.

The front page still display the product's thumbnail within even the product was in a hidden category, and same problem with the product still display on a subcategory.

 

I try to modify the fb_new_product.php myself and only can hide the product thumbnail which this product was in a hidden category.

but if a product was in a subcategory and parent category hidden, product cannot be hidden.

 

ie:

 

A category -> B subcategory -> C product 

 

after my modification, when A category turn on and hidden B subcategory, the result will be no C product thumbnail display on front page.

but when A category been hidden and B subcategory turn on, the result will be C product thumbnail display on front page.

 

below is the code.

 

    function execute() {
      global $oscTemplate, $languages_id, $language, $currencies, $PHP_SELF, $cPath;
 
      if ($PHP_SELF == 'index.php' && $cPath == '') {
        // Set the text to display on the front page
        $new_prods_content = '<!-- New Products BOF -->' . "\n";
        if( constant( 'MODULE_FRONT_PAGE_NEW_PRODUCTS_TITLE_' . strtoupper( $language ) ) != '') {
          $new_prods_content .= '  <h2>' . sprintf( constant( 'MODULE_FRONT_PAGE_NEW_PRODUCTS_TITLE_' . strtoupper( $language ) ), strftime('%B')) . '</h2>' . "\n";
        }
        $new_prods_content .= '  <div class="contentText">' . "\n";
 
       if ((!isset ($new_products_category_id)) || ($new_products_category_id == '0')) {//True means at front page position.
/*Below line was an original code.
         $new_products_query = tep_db_query( "select p.products_id,trim(substring(pd.products_description, 1, 90)) as products_description, p.products_image, p.products_tax_class_id, pd.products_name, if(s.status, s.specials_new_products_price, p.products_price) as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_new_display_status = '1' and p.products_id = pd.products_id and pd.language_id = '" . (int) $languages_id . "' order by p.products_date_added desc limit " . MODULE_FRONT_PAGE_NEW_PRODUCTS_MAX_DISPLAY); //Query for Top most front page thrumbnail. //No consider about category status.
*/
/* Below line was my modified code.*/
          $new_products_query = tep_db_query( "select p.products_id,trim(substring(pd.products_description, 1, 90)) as products_description, p.products_image, p.products_tax_class_id, pd.products_name, if(s.status, s.specials_new_products_price, p.products_price) as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_DESCRIPTION . " pd, ". TABLE_PRODUCTS_TO_CATEGORIES ." p2c, " . TABLE_CATEGORIES . " c where p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and c.status_categ = 1 and p.products_status = '1' and p.products_new_display_status = '1' and p.products_id = pd.products_id and pd.language_id = '" . (int) $languages_id . "' order by p.products_date_added desc limit " . MODULE_FRONT_PAGE_NEW_PRODUCTS_MAX_DISPLAY); //Query for Top most front page thrumbnail. //No consider about category status.
 
        } else { //If not at front page then means at sub category page position. once to here, fp not handle.
 
 //BOF Hide Categories with category cache.
         $new_products_query = tep_db_query( "select distinct p.products_id, trim(substring(pd.products_description, 1, 90)) as products_description, p.products_image, p.products_tax_class_id, pd.products_name, if(s.status, s.specials_new_products_price, p.products_price) as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c where p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and c.parent_id = '" . (int) $new_products_category_id . "'and p.products_status = '1' and p.products_new_display_status = '1' and p.products_id = pd.products_id and pd.language_id = '" . (int) $languages_id . "' order by p.products_date_added desc limit " . MODULE_FRONT_PAGE_NEW_PRODUCTS_MAX_DISPLAY);
//Query for Subcategories front page thrumbnail.
//EOF Hide Categories with category cache.
 
        }
 

I m appreciate if anyone can help me solve my problem.

 

Many thanks.

Share this post


Link to post
Share on other sites

The hidden categories with category cache contribution creates an array of hidden category ids called $hiddencats in application_top that is available for use wherever you need to restrict product display. The array includes all categories that are directly marked as hidden as well as all categories that are not marked hidden but have a parent category that is hidden. Since you need this array inside a function you will need to include it in your list of global variables. If the array is empty there are no hidden categories so you need to test to see if it is empty since the implode function will fail if used on an empty array. When not empty you need to check to make sure the category is not included in the array so instead of the "c.status_categ = 1" your query would include a test like this:

 

and c.categories_id not in (" . implode(',', $hiddencats) . ")

 

If you need an example look at instruction 13 of the install instructions for the hidden categories contribution.

 

Hi All,

 

Did anyone installed and work on Modular Front Page 1.4?! I had this module installed which will replace the original front page,

this module has a file called fp_new_product.php which will replace the original index.php to handle the front page.

 

Unfortunately, hide categories with category cache does not included any code for Modular Front Page.

 

My problem is 

When I finished installing Hide categories with category cache, everything seem work fine except the front page.

The front page still display the product's thumbnail within even the product was in a hidden category, and same problem with the product still display on a subcategory.

 

I try to modify the fb_new_product.php myself and only can hide the product thumbnail which this product was in a hidden category.

but if a product was in a subcategory and parent category hidden, product cannot be hidden.

 

ie:

 

A category -> B subcategory -> C product 

 

after my modification, when A category turn on and hidden B subcategory, the result will be no C product thumbnail display on front page.

but when A category been hidden and B subcategory turn on, the result will be C product thumbnail display on front page.

 

below is the code.

 

    function execute() {
      global $oscTemplate, $languages_id, $language, $currencies, $PHP_SELF, $cPath;
 

....

 

/* Below line was my modified code.*/

          $new_products_query = tep_db_query( "select p.products_id,trim(substring(pd.products_description, 1, 90)) as products_description, p.products_image, p.products_tax_class_id, pd.products_name, if(s.status, s.specials_new_products_price, p.products_price) as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_DESCRIPTION . " pd, ". TABLE_PRODUCTS_TO_CATEGORIES ." p2c, " . TABLE_CATEGORIES . " c where p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and c.status_categ = 1 and p.products_status = '1' and p.products_new_display_status = '1' and p.products_id = pd.products_id and pd.language_id = '" . (int) $languages_id . "' order by p.products_date_added desc limit " . MODULE_FRONT_PAGE_NEW_PRODUCTS_MAX_DISPLAY); //Query for Top most front page thrumbnail. //No consider about category status.
 
        } else { //If not at front page then means at sub category page position. once to here, fp not handle.
 
 //BOF Hide Categories with category cache.
         $new_products_query = tep_db_query( "select distinct p.products_id, trim(substring(pd.products_description, 1, 90)) as products_description, p.products_image, p.products_tax_class_id, pd.products_name, if(s.status, s.specials_new_products_price, p.products_price) as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c where p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and c.parent_id = '" . (int) $new_products_category_id . "'and p.products_status = '1' and p.products_new_display_status = '1' and p.products_id = pd.products_id and pd.language_id = '" . (int) $languages_id . "' order by p.products_date_added desc limit " . MODULE_FRONT_PAGE_NEW_PRODUCTS_MAX_DISPLAY);
//Query for Subcategories front page thrumbnail.
//EOF Hide Categories with category cache.
 
        }
 

I m appreciate if anyone can help me solve my problem.

 

Many thanks.

Share this post


Link to post
Share on other sites

×