Jump to content


Corporate Sponsors


Latest News: (loading..)

* * * * * 5 votes

A Store Speed Optimization in Progress


897 replies to this topic

#81 chardae

  • Community Member
  • 73 posts
  • Real Name:Charlotte Black
  • Location:Paradise California

Posted 06 November 2004, 22:08

chardae, on Nov 6 2004, 03:00 PM, said:

LOL :D
:'( Bugs Yuck! :blink:
But I for one like small bugs better than big bugs!

<{POST_SNAPBACK}>


Ok I had an Idea to help solve this and so far its working for me.
I created a new file called breadcrumb.php and placed the code you moved to the header there, deleted the code from the header then called the breadcrumb.php file at the bottom of application_top. It seems to be working like this. I will test it a little more then send it over to you.

Edited by chardae, 06 November 2004, 22:09.

:)

#82 Chemo

  • Banned
  • 2,486 posts
  • Real Name:Bobby
  • Location:/usa/kentucky/richmond/

Posted 06 November 2004, 22:13

That will present problems since the breadcrumb trail URL's will be malformed due to the tep_href_link() code change. It will only affect those that are not logged in and have cookies disabled.

#83 Chemo

  • Banned
  • 2,486 posts
  • Real Name:Bobby
  • Location:/usa/kentucky/richmond/

Posted 07 November 2004, 01:14

If you've installed the version 1.3 and want to try the fix for the breadcrumb trail on non-cached pages here is the beta code:
<{POST_SNAPBACK}>

A fix that I'm exploring is changing the add() method in /includes/classes/breadcrumb.php to:
    function add($title, $link = '', $unshift = 0) {   
   switch ($unshift) {
    case 0:
 	 $this->_trail[] = array('title' => $title, 'link' => $link);
 	 break;
  case 1:
 	 array_unshift($this->_trail, array('title' => $title, 'link' => $link)); 	 
 	 break;
   }      
    }

Then, in includes/header.php change the index page breadcrumb addition to this:
$breadcrumb->add(HEADER_TITLE_CATALOG, tep_href_link(FILENAME_DEFAULT), 1);
It works by the new switch (3rd parameter). If it is set as 1 it will add to the beginning of the breadcrumb trail. I've just added it to the dev site and am still testing it. If you install the beta code let me know how it works for you...

BTW, for those that have the store in a folder and NOT the root directory like the dev site: you'll have to add them in reverse order with the unshift flag set to 1.

As an example, this:
$breadcrumb->add(HEADER_TITLE_TOP, HTTP_SERVER);
$breadcrumb->add(HEADER_TITLE_CATALOG, tep_href_link(FILENAME_DEFAULT));
Becomes this:
$breadcrumb->add(HEADER_TITLE_CATALOG, tep_href_link(FILENAME_DEFAULT), 1);
$breadcrumb->add(HEADER_TITLE_TOP, HTTP_SERVER, 1);


#84 chardae

  • Community Member
  • 73 posts
  • Real Name:Charlotte Black
  • Location:Paradise California

Posted 07 November 2004, 19:01

Chemo, on Nov 6 2004, 06:14 PM, said:

If you've installed the version 1.3 and want to try the fix for the breadcrumb trail on non-cached pages here is the beta code:
<{POST_SNAPBACK}>

A fix that I'm exploring is changing the add() method in /includes/classes/breadcrumb.php to:
    function add($title, $link = '', $unshift = 0) {   
   switch ($unshift) {
    case 0:
  	$this->_trail[] = array('title' => $title, 'link' => $link);
  	break;
  case 1:
  	array_unshift($this->_trail, array('title' => $title, 'link' => $link));  	
  	break;
   }      
    }

Then, in includes/header.php change the index page breadcrumb addition to this:
$breadcrumb->add(HEADER_TITLE_CATALOG, tep_href_link(FILENAME_DEFAULT), 1);
It works by the new switch (3rd parameter).  If it is set as 1 it will add to the beginning of the breadcrumb trail.  I've just added it to the dev site and am still testing it.  If you install the beta code let me know how it works for you...

BTW, for those that have the store in a folder and NOT the root directory like the dev site: you'll have to add them in reverse order with the unshift flag set to 1.

As an example, this:
$breadcrumb->add(HEADER_TITLE_TOP, HTTP_SERVER);
$breadcrumb->add(HEADER_TITLE_CATALOG, tep_href_link(FILENAME_DEFAULT));
Becomes this:
$breadcrumb->add(HEADER_TITLE_CATALOG, tep_href_link(FILENAME_DEFAULT), 1);
$breadcrumb->add(HEADER_TITLE_TOP, HTTP_SERVER, 1);

<{POST_SNAPBACK}>


Thanks Again Chemo that seems to have done the trick. :thumbsup:
:)

#85 Chemo

  • Banned
  • 2,486 posts
  • Real Name:Bobby
  • Location:/usa/kentucky/richmond/

Posted 07 November 2004, 19:08

Outstanding...let's hear back from one more person that is is functioning properly and I'll release another version with updated install directions.

#86 teodorp

  • Community Member
  • 22 posts
  • Real Name:Teodor Pavlovich
  • Location:Bulgaria

Posted 07 November 2004, 20:31

Page Cache is a great contribution and now everything work fine!
I have to know...:)

#87 Terfexdotcom

  • Community Member
  • 61 posts
  • Real Name:Duncan Jones

Posted 07 November 2004, 21:12

Didnt work for me.

Put Catalog first

eg. (With it set to 1)
Catalog » Help Desk » Home
8 Oz Steel Hip Flask » Catalog » Gifts » Home

eg. (With it set to 0)
Contact Us » Home » Catalog
48" Decorative Sword » Home » Catalog » Swords »

eg. (with it set to 1 and things reversed)
Catalog » 3pc "Tiger Claw" Knife Set » Home » Daggers »
Catalog » Contact Us » Home

eg. (with it set to 0 and things reversed)
Contact Us » Catalog » Home
Backpack/Rolling Cart (20" Tall) » Catalog » Home » Luggage »

Edited by Terfexdotcom, 07 November 2004, 21:16.

---------------------------------
Duncan Jones

#88 Chemo

  • Banned
  • 2,486 posts
  • Real Name:Bobby
  • Location:/usa/kentucky/richmond/

Posted 07 November 2004, 21:19

Terfexdotcom, on Nov 7 2004, 04:12 PM, said:

Didnt work for me.

Put Catalog first

eg. (With it set to 1)
Catalog » Help Desk » Home
8 Oz Steel Hip Flask » Catalog » Gifts » Home

eg. (With it set to 0)
Contact Us » Home » Catalog
48" Decorative Sword » Home » Catalog » Swords »

eg. (with it set to 1 and things reversed)
Catalog » 3pc "Tiger Claw" Knife Set » Home » Daggers »
Catalog » Contact Us » Home

eg. (with it set to 0 and things reversed)
Contact Us » Catalog » Home
Backpack/Rolling Cart (20" Tall) » Catalog » Home » Luggage »

<{POST_SNAPBACK}>

First, you have the catalog in your root directory but still have both URL's added to the breadcrumb. It's a common mistake so don't worry too much about that but here is your fix:
Change:
$breadcrumb->add(HEADER_TITLE_TOP, HTTP_SERVER);
$breadcrumb->add(HEADER_TITLE_CATALOG, tep_href_link(FILENAME_DEFAULT));
To this:
$breadcrumb->add(HEADER_TITLE_TOP, HTTP_SERVER, 1);
#$breadcrumb->add(HEADER_TITLE_CATALOG, tep_href_link(FILENAME_DEFAULT));
Also, make sure you made the changes to /includes/classes/breadcrumb.php as mentioned in the beta code.

Edited by Chemo, 07 November 2004, 21:20.


#89 Terfexdotcom

  • Community Member
  • 61 posts
  • Real Name:Duncan Jones

Posted 07 November 2004, 21:21

It seems my pages arent cacheing now... Havent changed anything.

Index.php
Current Parse Time: 0.179 s with 63 queries
Current Parse Time: 0.180 s with 63 queries
Current Parse Time: 0.181 s with 63 queries

Product_Info.php
Current Parse Time: 0.153 s with 76 queries
Current Parse Time: 0.153 s with 76 queries
Current Parse Time: 0.155 s with 76 queries

DAMN IT!! Only thing ive done to those settings is change delete cache to true which then changed to false.
---------------------------------
Duncan Jones

#90 Terfexdotcom

  • Community Member
  • 61 posts
  • Real Name:Duncan Jones

Posted 07 November 2004, 21:24

Chemo, on Nov 7 2004, 09:19 PM, said:

First, you have the catalog in your root directory but still have both URL's added to the breadcrumb.  It's a common mistake so don't worry too much about that but here is your fix:
Change:
$breadcrumb->add(HEADER_TITLE_TOP, HTTP_SERVER);
$breadcrumb->add(HEADER_TITLE_CATALOG, tep_href_link(FILENAME_DEFAULT));
To this:
$breadcrumb->add(HEADER_TITLE_TOP, HTTP_SERVER, 1);
#$breadcrumb->add(HEADER_TITLE_CATALOG, tep_href_link(FILENAME_DEFAULT));
Also, make sure you made the changes to /includes/classes/breadcrumb.php as mentioned in the beta code.

<{POST_SNAPBACK}>


Made this change and now the result is -
Home » Backpack/Rolling Cart (20" Tall) » Luggage »
Home » Contact Us
Home » Diamond Cut Knife Set (21pc) » Knives » Kitchen »
---------------------------------
Duncan Jones

#91 Terfexdotcom

  • Community Member
  • 61 posts
  • Real Name:Duncan Jones

Posted 07 November 2004, 21:32

Terfexdotcom, on Nov 7 2004, 09:21 PM, said:

It seems my pages arent cacheing now... Havent changed anything.

Index.php
Current Parse Time: 0.179 s with 63 queries
Current Parse Time: 0.180 s with 63 queries
Current Parse Time: 0.181 s with 63 queries

Product_Info.php
Current Parse Time: 0.153 s with 76 queries
Current Parse Time: 0.153 s with 76 queries
Current Parse Time: 0.155 s with 76 queries

DAMN IT!! Only thing ive done to those settings is change delete cache to true which then changed to false.

<{POST_SNAPBACK}>


Fixed it, I had to MANUALLY change the delete cache files to false (by the first page refreshed after set to true). It was set as false in settings but upon doing debug saw this. [PAGE_CACHE_DELETE_FILES] => true

So went in and clicked update and updated the setting to false. Works great now.
---------------------------------
Duncan Jones

#92 Chemo

  • Banned
  • 2,486 posts
  • Real Name:Bobby
  • Location:/usa/kentucky/richmond/

Posted 07 November 2004, 21:37

Which version do you have installed? Did you follow the upgrade directions? Did you move the breadcrumb code out of application_top.ph and into header.php?

#93 Chemo

  • Banned
  • 2,486 posts
  • Real Name:Bobby
  • Location:/usa/kentucky/richmond/

Posted 07 November 2004, 21:42

Terfexdotcom, on Nov 7 2004, 04:32 PM, said:

Fixed it, I had to MANUALLY change the delete cache files to false (by the first page refreshed after set to true). It was set as false in settings but upon doing debug saw this. [PAGE_CACHE_DELETE_FILES] => true

So went in and clicked update and updated the setting to false. Works great now.

<{POST_SNAPBACK}>

Upgrade to v1.3 and follow the upgrade directions. You have to move the breadcrumb code to header.php for this to work properly.

I checked your site with a non-cookied site and noticed that the breadcrumb is still being added in applicaiton_top.php

#94 Terfexdotcom

  • Community Member
  • 61 posts
  • Real Name:Duncan Jones

Posted 07 November 2004, 21:49

I did upgrade to V1.3!

In application top -

// include the breadcrumb class and start the breadcrumb trail
  require(DIR_WS_CLASSES . 'breadcrumb.php');
  $breadcrumb = new breadcrumb;
 /*
  $breadcrumb->add(HEADER_TITLE_TOP, HTTP_SERVER);
 // $breadcrumb->add(HEADER_TITLE_CATALOG, tep_href_link(FILENAME_DEFAULT));

In header.php
<?php
$breadcrumb->add(HEADER_TITLE_TOP, HTTP_SERVER, 1);
#$breadcrumb->add(HEADER_TITLE_CATALOG, tep_href_link(FILENAME_DEFAULT));
// add category names or the manufacturer name to the breadcrumb trail

Only time this wouldnt be true is on the secure pages which im yet to change.

Edited by Terfexdotcom, 07 November 2004, 21:51.

---------------------------------
Duncan Jones

#95 Chemo

  • Banned
  • 2,486 posts
  • Real Name:Bobby
  • Location:/usa/kentucky/richmond/

Posted 07 November 2004, 22:18

Terfexdotcom,

It hits me that you have some other SEO contribution installed that adds the product name to the page title and also the breadcrumb.

You need to move the SEO breadcrumb addition to below the rest of them in header.php

#96 chardae

  • Community Member
  • 73 posts
  • Real Name:Charlotte Black
  • Location:Paradise California

Posted 08 November 2004, 00:39

Chemo,

I am attempting to impliment the tax class and need to know how I can make it work with the tax emempt mod. Here is the tax code in place in general.php for tax exempt.

////
// Returns the tax rate for a zone / class
// TABLES: tax_rates, zones_to_geo_zones

// BEGIN - Tax Exempt and Organization Discounts
// old:function tep_get_tax_rate($class_id, $country_id = -1, $zone_id = -1) {
  function tep_get_tax_rate($class_id, $country_id = -1, $zone_id = -1, $tax_exempt = -1) {
// END - Tax Exempt and Organization Discounts

    global $customer_zone_id, $customer_country_id;
// BEGIN - Tax Exempt and Organization Discounts
    if ($tax_exempt == 1) { return 0; }
// END - Tax Exempt and Organization Discounts

    if ( ($country_id == -1) && ($zone_id == -1) ) {
      if (!tep_session_is_registered('customer_id')) {
        $country_id = STORE_COUNTRY;
        $zone_id = STORE_ZONE;
      } else {
        $country_id = $customer_country_id;
        $zone_id = $customer_zone_id;
      }
    }

    $tax_query = tep_db_query("select sum(tax_rate) as tax_rate from " . TABLE_TAX_RATES . " tr left join " . TABLE_ZONES_TO_GEO_ZONES . " za on (tr.tax_zone_id = za.geo_zone_id) left join " . TABLE_GEO_ZONES . " tz on (tz.geo_zone_id = tr.tax_zone_id) where (za.zone_country_id is null or za.zone_country_id = '0' or za.zone_country_id = '" . (int)$country_id . "') and (za.zone_id is null or za.zone_id = '0' or za.zone_id = '" . (int)$zone_id . "') and tr.tax_class_id = '" . (int)$class_id . "' group by tr.tax_priority");
    if (tep_db_num_rows($tax_query)) {
      $tax_multiplier = 1.0;
      while ($tax = tep_db_fetch_array($tax_query)) {
        $tax_multiplier *= 1.0 + ($tax['tax_rate'] / 100);
      }
      return ($tax_multiplier - 1.0) * 100;
    } else {
      return 0;
    }
  }

////
// Return the tax description for a zone / class
// TABLES: tax_rates;
// BEGIN - Tax Exempt and Organization Discounts
  function tep_get_tax_description($class_id, $country_id, $zone_id, $tax_exempt) {
    if ($tax_exempt == 1) { return TEXT_TAX_EXEMPT; }
// END - Tax Exempt and Organization Discounts
 
    $tax_query = tep_db_query("select tax_description from " . TABLE_TAX_RATES . " tr left join " . TABLE_ZONES_TO_GEO_ZONES . " za on (tr.tax_zone_id = za.geo_zone_id) left join " . TABLE_GEO_ZONES . " tz on (tz.geo_zone_id = tr.tax_zone_id) where (za.zone_country_id is null or za.zone_country_id = '0' or za.zone_country_id = '" . (int)$country_id . "') and (za.zone_id is null or za.zone_id = '0' or za.zone_id = '" . (int)$zone_id . "') and tr.tax_class_id = '" . (int)$class_id . "' order by tr.tax_priority");
    if (tep_db_num_rows($tax_query)) {
      $tax_description = '';
      while ($tax = tep_db_fetch_array($tax_query)) {
        $tax_description .= $tax['tax_description'] . ' + ';
      }
      $tax_description = substr($tax_description, 0, -3);

      return $tax_description;
    } else {
      return TEXT_UNKNOWN_TAX_RATE;
    }
  }

////
// Add tax to a products price
  function tep_add_tax($price, $tax) {
    global $currencies;

    if ( (DISPLAY_PRICE_WITH_TAX == 'true') && ($tax > 0) ) {
      return tep_round($price, $currencies->currencies[DEFAULT_CURRENCY]['decimal_places']) + tep_calculate_tax($price, $tax);
    } else {
      return tep_round($price, $currencies->currencies[DEFAULT_CURRENCY]['decimal_places']);
    }
  }

// Calculates Tax rounding the result
  function tep_calculate_tax($price, $tax) {
    global $currencies;

    return tep_round($price * $tax / 100, $currencies->currencies[DEFAULT_CURRENCY]['decimal_places']);
  }

Any ideas of what I need to do to make it work with the tax.php?
:)

#97 Chemo

  • Banned
  • 2,486 posts
  • Real Name:Bobby
  • Location:/usa/kentucky/richmond/

Posted 08 November 2004, 01:03

Try this code:
////
// Returns the tax rate for a zone / class
// TABLES: tax_rates, zones_to_geo_zones
 function tep_get_tax_rate($class_id, $country_id = -1, $zone_id = -1, $tax_exempt = -1) {
    global $customer_zone_id, $customer_country_id, $osC_Tax;
	// BEGIN - Tax Exempt and Organization Discounts
	if ($tax_exempt == 1) { return 0; }
	// END - Tax Exempt and Organization Discounts
	else { return $osC_Tax->getTaxRate($class_id, $country_id, $zone_id); }	
  }

////
// Return the tax description for a zone / class
// TABLES: tax_rates;
 function tep_get_tax_description($class_id, $country_id, $zone_id, $tax_exempt) {
	global $osC_Tax;
	if ($tax_exempt == 1) { return TEXT_TAX_EXEMPT; }
	else { return $osC_Tax->getTaxRateDescription($class_id, $country_id, $zone_id); }
  }

////
// Add tax to a products price
  function tep_add_tax($price, $tax) {
    global $currencies;

    if ( (DISPLAY_PRICE_WITH_TAX == 'true') && ($tax > 0) ) {
      return tep_round($price, $currencies->currencies[DEFAULT_CURRENCY]['decimal_places']) + tep_calculate_tax($price, $tax);
    } else {
      return tep_round($price, $currencies->currencies[DEFAULT_CURRENCY]['decimal_places']);
    }
  }

// Calculates Tax rounding the result
  function tep_calculate_tax($price, $tax) {
    global $currencies;

    return tep_round($price * $tax / 100, $currencies->currencies[DEFAULT_CURRENCY]['decimal_places']);
  }
The only methods that would change are tep_get_tax_rate() and tep_get_tax_description()

Edited by Chemo, 08 November 2004, 01:05.


#98 chardae

  • Community Member
  • 73 posts
  • Real Name:Charlotte Black
  • Location:Paradise California

Posted 08 November 2004, 04:01

That seems to have fixed it, Once again you are a life saver.
:)

#99 Chemo

  • Banned
  • 2,486 posts
  • Real Name:Bobby
  • Location:/usa/kentucky/richmond/

Posted 08 November 2004, 04:24

As a side note, since I'm so big on debugging, do you have the Queries and Parse time contribution installed? If so, you can change the contents of includes/performance.php to read as follows:
if (DISPLAY_PAGE_PARSE_TIME == 'true') {
$debug['TAX_RATES'] = $osC_Tax->tax_rates;
$time_start = explode(' ', PAGE_PARSE_START_TIME);
$time_end = explode(' ', microtime());
$parse_time = number_format(($time_end[1] + $time_end[0] - ($time_start[1] + $time_start[0])), 3);
echo '<div align="center"><span class="smallText">Current Parse Time: <b>' . $parse_time . ' s</b> with <b>'.sizeof($debug['QUERIES']).' queries</b></span></div>';
if ($_REQUEST['output'] == '0') $_SESSION['output'] = '0';
if ($_REQUEST['output'] == '1' || $_SESSION['output'] == '1')
	{
  $_SESSION['output'] = '1';
  echo '<pre>';
  print_r($debug);
  echo '</pre>';
	} # END if request
}
unset($debug);
This will add the tax rates used on that page as part of the debug array. If it were me I'd want to know if the contribution actually worked :)

#100 chardae

  • Community Member
  • 73 posts
  • Real Name:Charlotte Black
  • Location:Paradise California

Posted 08 November 2004, 07:05

Chemo, on Nov 7 2004, 09:24 PM, said:

As a side note, since I'm so big on debugging, do you have the Queries and Parse time contribution installed?  If so, you can change the contents of includes/performance.php to read as follows:
if (DISPLAY_PAGE_PARSE_TIME == 'true') {
$debug['TAX_RATES'] = $osC_Tax->tax_rates;
$time_start = explode(' ', PAGE_PARSE_START_TIME);
$time_end = explode(' ', microtime());
$parse_time = number_format(($time_end[1] + $time_end[0] - ($time_start[1] + $time_start[0])), 3);
echo '<div align="center"><span class="smallText">Current Parse Time: <b>' . $parse_time . ' s</b> with <b>'.sizeof($debug['QUERIES']).' queries</b></span></div>';
if ($_REQUEST['output'] == '0') $_SESSION['output'] = '0';
if ($_REQUEST['output'] == '1' || $_SESSION['output'] == '1')
	{
  $_SESSION['output'] = '1';
  echo '<pre>';
  print_r($debug);
  echo '</pre>';
	} # END if request
}
unset($debug);
This will add the tax rates used on that page as part of the debug array.  If it were me I'd want to know if the contribution actually worked :)

<{POST_SNAPBACK}>



Thanks Again Chemo. and Yes it does work. I haven't had any problems with it so far anyway but I am still in the building and learning stage.

BTW pm me with some rates if interested in a custom modification for my site.
:)