Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

Variant performance improvement in 4.0

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #1  
Old 09-12-2006, 09:58 PM
 
geckoday geckoday is offline
 

X-Wizard
  
Join Date: Aug 2005
Posts: 1,073
 

Default 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.
__________________
Manuka Bay Company
X-Cart Version 4.0.19 [Linux]

UGG Boots and other fine sheepskin products
http://www.snowriver.com
Reply With Quote
  #2  
Old 10-30-2006, 01:40 PM
 
consolep consolep is offline
 

Member
  
Join Date: Jun 2006
Posts: 17
 

Default 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.
__________________
Xcart v4.0.18 Current one
Reply With Quote
  #3  
Old 11-07-2006, 12:53 PM
 
trickyjoe trickyjoe is offline
 

Member
  
Join Date: Jul 2006
Posts: 16
 

Default Re: Variant performance improvement in 4.0

Just wondered if you have had a go with this yet???
__________________
www.rollersnakes.co.uk
4.0.19 [getting faster]
2 x dedicated servers, Dual Quad Core processors, 16gb ram, Raid 0 for the os, Raid 5 for the data and a whole host of tweaks. Some might say its a little over kill for one site
Reply With Quote
  #4  
Old 01-30-2007, 10:27 AM
 
jeanne jeanne is offline
 

Advanced Member
  
Join Date: Aug 2004
Posts: 85
 

Default Re: Variant performance improvement in 4.0

Thanks, this is working well on my 4.0.18 installation.
Jeanne
4.0.18 gold
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 03:04 AM.

   

 
X-Cart forums © 2001-2020