Ok, so I know nothing of smarty, however I am good with PHP. And it appears (I think) that the reason it is so slow is because it opens category-tree-branch.tpl again for each separate category when populating the block.
Anyways, attached is a mod of the categories block renamed to "blockcategoriescache". It should be completely independent (renamed files, changed module name, module variable names, etc) so you can just upload and test. Also, as I said I don't know smarty, this is very primitive. You have to update the cache manually every time you change/update your category list. Basically, this SHOULD work fine, but I make no guarantees.
Also, to clock the page generation time to see if there is an increase, add 2 lines in index.php. Change it from this:
<?php
include(dirname(__FILE__).'/config/config.inc.php');
if(intval(Configuration::get('PS_REWRITING_SETTINGS')) === 1)
$rewrited_url = __PS_BASE_URI__;
include(dirname(__FILE__).'/header.php');
$smarty->assign('HOOK_HOME', Module::hookExec('home'));
$smarty->display(_PS_THEME_DIR_.'index.tpl');
include(dirname(__FILE__).'/footer.php');
?>
to
<?php
$dwTimeStart = microtime(true);
include(dirname(__FILE__).'/config/config.inc.php');
if(intval(Configuration::get('PS_REWRITING_SETTINGS')) === 1)
$rewrited_url = __PS_BASE_URI__;
include(dirname(__FILE__).'/header.php');
$smarty->assign('HOOK_HOME', Module::hookExec('home'));
$smarty->display(_PS_THEME_DIR_.'index.tpl');
include(dirname(__FILE__).'/footer.php');
echo(round(microtime(true) - $dwTimeStart, 3) . "s");
?>
Whenever you load the main page, it will display the seconds it took to generate the page on the bottom.
Installation Instructions:
1.) OPTIONAL - Change the index page as indicated above so you can see performance impact.
2.) OPTIONAL - Load main page 3 times and average page generation times
3.) Download attachment, extract
4.) Upload "blockcategoriescache" to www.YOUR-SITE.com/modules/blockcategoriescache
5.) On modules list in prestashop backoffice, uninstall "Categories block" and install "Categories block (Cache)"
6.) Update cache - goto www.YOUR-SITE.com/?debug=cat (You will need to do this each time you update categories)
7.) Load page and see speed increase
8.) OPTIONAL - Load main page 3 times and average page generation times. Post old and new times on this thread.
Anyone very familiar with modules PLEASE look at this to make sure everything is done nicely and stable. Also, I would REALLY appreciate it if people would post old and new page load times here.
Oh, and if you have any issues with it, post here and I will try my best to help.
Thanks!




Back to top









