Page 1 of 1

Cache for categories count

Posted: Tue Mar 27, 2018 11:38 am
by xinxilas
I have a lot of Categories, so it slowed down my site.

So i read here to disable categories count , it woked, but i like categories count , is there any way to count categories with an trigger and saves each categories count?

Thank you, Renato!

Re: Cache for categories count

Posted: Tue Mar 27, 2018 12:34 pm
by IP_CAM
Well, some Mod's exist for this, at least for OC 1.5.x Versions. But I just compared a v.3.0.2.x
D:\... \OC_3.0.2.0\catalog\model\catalog\product.php File with my Version File,
and I found exactly the same Routine, as it exists in my v.1.5.6.x Version File:
OC Version v.3.0.2.x:

Code: Select all

		$query = $this->db->query($sql);

		return $query->row['total'];
	}
compared to:
DEFAULT OC v.1.5.6.5_rc File Content:

Code: Select all

		$query = $this->db->query($sql);

	return $query->row['total'];
}
In my OC v.1.5.6.5_rc, I implemented the NEW CACHE Code like shown below,
but with OC v.3.x, I don't believe, that this md5 and possibly $this-> still
works, but it should be a clacks for a Coder, to make this work in OC 2 + 3.x
Versions as well.

It's a highly efficient way, to speed up a system, in the most simple way. Another
Fix add's all Cat's and their 'Values' into one single File, then also placed in the
Cache Folder, but this way of doing it takes TWO steps, to get the RESULT, compared
with this very simple 1-step Flatfile-data way of doing it, so, one saves another
microsecond, and so keeps the prozessor a little cooler as well... :laugh:
( but don't worry, that's just small minded Swiss perfectionist thinking... ::) )

But by use of such a Modification, there is no more difference in Pageload speed,
regardless of, if Category Counting is on or off. And I like to 'keep' it on too!
---
MODIFIED OC Version 1.5.6.x :

Code: Select all

// JTI MOD  Category Product Numbers Cache
	//	$query = $this->db->query($sql);
	//  return $query->row['total'];

	$cacheid='product.gettotalproducts.'.md5($sql).(int)$customer_group_id;
	$total=$this->cache->get($cacheid);
	if ($total === null ) {
	$query = $this->db->query($sql);
		$total = $query->row['total'];
		$this->cache->set($cacheid,$total);
   }
	return $total;
}
// END JTI MOD Category Product Numbers Cache
I just hope, that someone will be willing, to make it work for you, and
probably a few others...
Good Luck ! ;)
Ernie
---
Source:
http://octurbo.com/caching-opencarts-category-counts/
---
The other 1.5.6.x Count Caching Solution from genious Weismann Web:
https://gist.github.com/weismannweb/a16 ... 89ca1d1209
---
Image

Re: Cache for categories count

Posted: Tue Mar 27, 2018 8:42 pm
by xinxilas
big thanks, ill give a try!