Post by sorcer » Thu Oct 20, 2011 5:08 am

I have a shop with 6k products. This function work very slow with header and side category menu, because there are double "foreach" (category, subcategory) in code.
catalog/model/catalog/product.php - getTotalProducts

some modify to use function for active category only (catalog/controller/module/category.php):

Code: Select all

Line 31: $categories = $this->model_catalog_category->getCategories(0);
Line 32: 		
Line 33: 		foreach ($categories as $category) {
Line 34: 			$children_data = array();
Line 35:			$children = $this->model_catalog_category->getCategories($category['category_id']);
Line 36:			foreach ($children as $child) {
Line 37:				$data = array(
Line 38:					'filter_category_id'  => $child['category_id'],
Line 39:					'filter_sub_category' => true
Line 40:				);		
Line 41:					
Line 42:				if($child['parent_id'] == $this->data['category_id']){
Line 43:					$product_total = $this->model_catalog_product->getTotalProducts($data);
Line 44:					$children_data[] = array(
Line 45:						'category_id' => $child['category_id'],
Line 46:						'name'        => $child['name'] . ' (' . $product_total . ')',
Line 47:						'href'        => $this->url->link('product/category', 'path=' . $category['category_id'] . '_' . $child['category_id'])	
Line 48:					);					
Line 49:				}else{
Line 50:					$children_data[] = array(
Line 51:						'category_id' => $child['category_id'],
Line 52:						'name'        => $child['name'],
Line 53:						'href'        => $this->url->link('product/category', 'path=' . $category['category_id'] . '_' . $child['category_id'])	
Line 54:					);	
Line 55:				}
Line 56:			}
but shop still is very slow, any ideas?
If I change $product_total = $this->model_catalog_product->getTotalProducts($data); to $product_total=1; (in original category.php - Line 44 & Line 58) then site work perfect.

shop url: http://okompiuteriai.lt/

User avatar
Newbie

Posts

Joined
Thu Sep 01, 2011 4:02 am

Post by SXGuy » Thu Oct 20, 2011 5:04 pm

probably a silly question but... have you increased gzip compression to 9?

Active Member

Posts

Joined
Sun Nov 08, 2009 2:07 am

Post by sorcer » Thu Oct 20, 2011 8:31 pm

SXGuy wrote:probably a silly question but... have you increased gzip compression to 9?
Yes, but I did't see much difference.
I switch off this function to sub-category (load time is normal now).

User avatar
Newbie

Posts

Joined
Thu Sep 01, 2011 4:02 am
Who is online

Users browsing this forum: No registered users and 18 guests