Jump to content
Sign in to follow this  
basilfawlty

Faster Page Loads

Recommended Posts

Installed and working. From +-8 seconds to +-5 seconds.

 

But i have a question. Is this compatible with SPPC (Hide products to some class of customers)????

Ref:

To enable the categories cache

Open includes/functions/general.php

 

Add on top

require('cache/cachefile.inc.php');

 

Find function tep_count_products_in_category($category_id, $include_inactive = false) {

Replace above function with this:

 

function tep_count_products_in_category($category_id, $include_inactive = false) {

$products_count = 0;

 

$catcounter = constant('CATCOUNT_' . strtoupper($category_id));

 

$products_count = $catcounter;

 

return $products_count;

}

 

my code:

// Return the number of products in a category
// TABLES: products, products_to_categories, categories
 function tep_count_products_in_category($category_id, $include_inactive = false) {

 // Unless Customer logged in show products
 // BOF Separate Pricing Per Customer, hide products and categories for groups
 global $sppc_customer_group_id;
 if(!tep_session_is_registered('sppc_customer_group_id')) {
 $customer_group_id = '0';
 } else {
  $customer_group_id = $sppc_customer_group_id;
 }
$products_count = 0;
if ($include_inactive == true) {
  $products_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c left join " . TABLE_CATEGORIES . " c using(categories_id) where p.products_id = p2c.products_id and p2c.categories_id = '" . (int)$category_id . "' and find_in_set('".$customer_group_id."', products_hide_from_groups) = 0 and find_in_set('" . $customer_group_id . "', categories_hide_from_groups) = 0");
} else {
  $products_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c left join " . TABLE_CATEGORIES . " c using(categories_id) where p.products_id = p2c.products_id and p.products_status = '1' and p2c.categories_id = '" . (int)$category_id . "' and find_in_set('".$customer_group_id."', products_hide_from_groups) = 0 and find_in_set('" . $customer_group_id . "', categories_hide_from_groups) = 0");
}  
	$products = tep_db_fetch_array($products_query);
$products_count += $products['total'];
// no need to find child categories that are hidden from this customer or have a higher level category that is hidden
$child_categories_query = tep_db_query("select categories_id from " . TABLE_CATEGORIES . " where parent_id = '" . (int)$category_id . "' and find_in_set('" . $customer_group_id . "', categories_hide_from_groups) = 0");
// EOF Separate Pricing Per Customer, hide products and categories for groups
if (tep_db_num_rows($child_categories_query)) {
  while ($child_categories = tep_db_fetch_array($child_categories_query)) {
	$products_count += tep_count_products_in_category($child_categories['categories_id'], $include_inactive);
  }
}

return $products_count;
 }

 

I dont know if i must simply replace all that code... but loosing the ability to hide products to customers.

 

I see the same code on top of admin/includes/configuration_cache.php

Could I past the sppc code there???

 

In other case the instructions says:

8. Navigate to Admin ~ Configuration ~ My Store, click the edit button, and click the update button.

Where is that button. All I see is the Store Name xxxx on top and edit on the right. Is that??

Edited by bhbilbao

Share this post


Link to post
Share on other sites

I get a white page on products listings with sppc.

 

I edited the admin/includes/configuration_cache.php

 

and modified the

tep_function count_products_in_category

to

function count_products_in_category

 

example:

<?php
/*
$Id: configuration_cache.php,v 1.32 2004/04/06 20:24:09 daemonj Exp $
*/
$rQuery  = tep_db_query('SELECT `categories_id` FROM `categories`');
$aResult = array();
while ($r = tep_db_fetch_array($rQuery)) {
  $aResult[] = $r['categories_id'];
}

// Return the number of products in a category
// TABLES: products, products_to_categories, categories
 function count_products_in_category($category_id, $include_inactive = false) {

 // Unless Customer logged in show products
 // BOF Separate Pricing Per Customer, hide products and categories for groups
	 global $sppc_customer_group_id;
	 if(!tep_session_is_registered('sppc_customer_group_id')) {
	 $customer_group_id = '0';
	 } else {
	  $customer_group_id = $sppc_customer_group_id;
	 }
	$products_count = 0;
	if ($include_inactive == true) {
	  $products_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c left join " . TABLE_CATEGORIES . " c using(categories_id) where p.products_id = p2c.products_id and p2c.categories_id = '" . (int)$category_id . "' and find_in_set('".$customer_group_id."', products_hide_from_groups) = 0 and find_in_set('" . $customer_group_id . "', categories_hide_from_groups) = 0");
	} else {
	  $products_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c left join " . TABLE_CATEGORIES . " c using(categories_id) where p.products_id = p2c.products_id and p.products_status = '1' and p2c.categories_id = '" . (int)$category_id . "' and find_in_set('".$customer_group_id."', products_hide_from_groups) = 0 and find_in_set('" . $customer_group_id . "', categories_hide_from_groups) = 0");
	}
			$products = tep_db_fetch_array($products_query);
	$products_count += $products['total'];
// no need to find child categories that are hidden from this customer or have a higher level category that is hidden
	$child_categories_query = tep_db_query("select categories_id from " . TABLE_CATEGORIES . " where parent_id = '" . (int)$category_id . "' and find_in_set('" . $customer_group_id . "', categories_hide_from_groups) = 0");
// EOF Separate Pricing Per Customer, hide products and categories for groups
	if (tep_db_num_rows($child_categories_query)) {
	  while ($child_categories = tep_db_fetch_array($child_categories_query)) {
			$products_count += tep_count_products_in_category($child_categories['categories_id'], $include_inactive);
	  }
	}

	return $products_count;
 }


function count_has_category_subcategories($category_id) {

 

For the moment seems to work.

Edited by bhbilbao

Share this post


Link to post
Share on other sites

Sorry, doesnt work. In admin panel after saving a white page, and then in catalog stops to work.

Share this post


Link to post
Share on other sites

Also a white page with a modified products_new.php file:

 

index.php

<?php  
// needed for the new products module shown below
   $new_products_category_id = $current_category_id;
?>
<tr>
  <td><?php include(DIR_WS_MODULES . FILENAME_NEW_PRODUCTS); ?></td>
</tr>

 

 

includes/modules/products_new.php

<?php
 $info_box_contents = array();
 $info_box_contents[] = array('text' => sprintf(TABLE_HEADING_NEW_PRODUCTS, strftime('%B')));

//  new contentBoxHeading($info_box_contents);

 if ( (!isset($new_products_category_id)) || ($new_products_category_id == '0') ) {

  $new_products_query = tep_db_query("select p.products_id, p.products_quantity, 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 where p.latest_product='1' and p.products_status = '1' and p.products_id = pd.products_id and quotes_email_address NOT LIKE '%@%' and pd.language_id = '" . (int)$languages_id . "' and p.products_id = p2c.products_id " . $new_products_where . " order by p.products_date_added desc limit " . MAX_DISPLAY_NEW_PRODUCTS);


 } else {
  $new_products_query = tep_db_query("select distinct p.products_id, p.products_quantity, 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" . $new_products_where . " and c.parent_id = '" . (int)$new_products_category_id . "' and p.latest_product='1' and p.products_status = '1' and quotes_email_address NOT LIKE '%@%' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' order by p.products_date_added desc limit " . MAX_DISPLAY_NEW_PRODUCTS);

 }

 $row = 0;
 $col = 0;
 $info_box_contents = array();
 while ($new_products = tep_db_fetch_array($new_products_query)) {
   $new_products['products_name'] = tep_get_products_name($new_products['products_id']);

$sql = 'SELECT `products_short` FROM `products_description.............

 

 

Only works in product_listings pages. Im thinking on unistalling it and install Optimize Category Box as says Jan.

The contribution works great with a vanilla 2.2rca2 install, but not in a high modified case like me. Too much problems.

Share this post


Link to post
Share on other sites

Hi !

Many worry to adapt this addon to multishop addon.

Finally, i have tested the to-be-cached query into catalog/application_top.php:

select configuration_key as cfgKey, configuration_value as cfgValue from configuration

On the server that i use, this give me 388 lines in 0.0003 s. This is unsignifiant for a page during 0.500 s begin to end !

 

I dont have necessity to use this addon!

Please, make this test before to use this addon !!

 

J.D

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  

×