X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (https://forum.x-cart.com/forumdisplay.php?f=20)
-   -   Variant performance improvement in 4.0 (https://forum.x-cart.com/showthread.php?t=24876)

geckoday 09-12-2006 09:58 PM

Variant performance improvement in 4.0
 
More results from my profiling work. It seems when X-Cart is displaying the product page it gets pricing for each of the variants for the product. One of the things that requires is looking up the tax rates for the product. No matter which variant you are talking about the tax rate is the same but X-Cart calls a function to find out for every variant anyway. In one lower level function they they tried to cache the result to speed it up but they goofed and it only works for logged in users. This mod fixes the low level caching to work for not logged in users and adds caching at a higher level function for even more improvement. The performance improvement naturally depends on the number of variants the product has. On my test box I'm seeing roughly 1/4 second for 40 variants. On my faster production server its a little more than 1/2 that. It makes a product page with a lot of variants about as fast as one with only a couple of variants.

This is for version 4.0.x. Looks like at least 4.0.12 through 4.0.19. I guess X-Cart must have done some profiling too as they have added the higher level caching in 4.1 which is where the big gain is. I don't think 4.1 users will find any noticeable improvement if they were to implement the lower level cache fix only.

In func.php function func_get_customer_zones_avail find this:
PHP Code:

$customer_info[$address_prefix."country"] = $config["General"]["default_country"];
        
$customer_info[$address_prefix."state"] = $config["General"]["default_state"];
        
$customer_info[$address_prefix."county"] = $config["General"]["default_county"];
        
$customer_info[$address_prefix."zipcode"] = $config["General"]["default_zipcode"];
        
$customer_info[$address_prefix."city"] = $config["General"]["default_city"]; 

and add this line right after it:
PHP Code:

$customer_info["login"] = "!!!DEFAULT!!!"


Then in func.php function func_get_product_tax_rates find:
PHP Code:

$productid $product["productid"]; 


And replace it with this:
PHP Code:

static $tax_rates;
  static 
$last_productid;
  static 
$last_login;
    
    
$productid $product["productid"];
  
  if (
$productid == $last_productid && $login == $last_login)
    return 
$tax_rates;
  else {
    
$last_productid $productid;
    
$last_login $last_login;
  } 

WARNING: My tax is simple - one state, one rate. I don't display taxed prices on product pages. I am pretty confident this works but I haven't tested it outside my situation. Proceed with caution if you have complex taxation or display taxed prices on the product page.

consolep 10-30-2006 01:40 PM

Re: Variant performance improvement in 4.0
 
Interesting mod, ill definately check this one out as soon as i get the other mods installed :) Ill keep you updated.

trickyjoe 11-07-2006 12:53 PM

Re: Variant performance improvement in 4.0
 
Just wondered if you have had a go with this yet???

jeanne 01-30-2007 10:27 AM

Re: Variant performance improvement in 4.0
 
Thanks, this is working well on my 4.0.18 installation.
Jeanne
4.0.18 gold


All times are GMT -8. The time now is 03:50 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.