Our site started slowing down awfully as our number of products grew. The product info display page was worst, sometimes taking 8-9 seconds to load. I eventually tracked down the problem and we are back down to 3-4 seconds. Other pages have improved too, simply because the server isn't so busy reading files.
I really wanted to post this as I think zencart is a great product and I would hate to see people abandon it because of this issue.
We have additional images turned on. This module (module/additional_images.php)was reading every single image file in the images/products directory:
while ($file = $dir->read()) {
if (!is_dir($products_image_directory . $file)) {
if (substr($file, strrpos($file, '.')) == $file_extension) {
if(preg_match('/\Q' . $products_image_base . '\E/i', $file) == 1) {
if ($file != $products_image) {
if ($products_image_base . str_replace($products_image_base, '', $file) == $file) {
error_log('I AM A MATCH ' . $file);
$images_array[] = $file;
} else {
error_log('I AM NOT A MATCH ' . $file);
}
}
}
}
}
}
I replaced the above code with:
$searchstr = $products_image_directory . $products_image_base . "*" . $file_extension;
$matches = glob($searchstr);
if(is_array($matches) && !empty($matches)){
foreach($matches as $match){
$images_array[] = basename($match);
}
}
Hope this helps someone else and maybe it can go in the next release.
Bookmarks