Merge branch 'develop' of gitlab.antadis.net:dev-antadis/bebeboutik into develop
This commit is contained in:
commit
c87c99e38f
@ -24,30 +24,51 @@ class Privatesales_Family_Menu extends Module {
|
|||||||
global $cookie, $smarty;
|
global $cookie, $smarty;
|
||||||
|
|
||||||
$id_lang = (int)$cookie->id_lang;
|
$id_lang = (int)$cookie->id_lang;
|
||||||
|
/**
|
||||||
$filename = _PS_ROOT_DIR_.'/modules/privatesales_family_menu/menu_'.$id_lang.'.txt';
|
* @Override cache file
|
||||||
$expire = time() -3600;
|
*/
|
||||||
|
if (class_exists('CacheRedis')) {
|
||||||
if(file_exists($filename) && filemtime($filename) > $expire) {
|
$tpl_cache_name = 'sale_privatesales_family_menu_'.(int) $cookie->id_lang.'.html';
|
||||||
$data = file_get_contents($filename);
|
if (false === ($result = CacheRedis::getInstance()->get($tpl_cache_name, 'privatesales_family_menu'))) {
|
||||||
$menus = json_decode($data, TRUE);
|
$menus = $this->getTree($cookie->id_lang);
|
||||||
|
if (!$menus) {
|
||||||
|
CacheRedis::getInstance()->set($tpl_cache_name, 'privatesales_family_menu', '', CacheRedis::MEDIUM_TTL);
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
$smarty->assign(array(
|
||||||
|
'menus' => $menus
|
||||||
|
));
|
||||||
|
$result = $this->display(__FILE__, 'menu.tpl');
|
||||||
|
CacheRedis::getInstance()->set($tpl_cache_name, 'privatesales_family_menu', $result, CacheRedis::MEDIUM_TTL);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$file = fopen($filename, 'w+');
|
$filename = _PS_ROOT_DIR_.'/modules/privatesales_family_menu/menu_'.$id_lang.'.txt';
|
||||||
$menus = $this->getTree($cookie->id_lang);
|
$expire = time() -3600;
|
||||||
fwrite($file, json_encode($menus));
|
|
||||||
fclose($file);
|
|
||||||
}
|
|
||||||
|
|
||||||
$smarty->assign(array(
|
if(file_exists($filename) && filemtime($filename) > $expire) {
|
||||||
'menus' => $menus
|
$data = file_get_contents($filename);
|
||||||
));
|
$menus = json_decode($data, TRUE);
|
||||||
return $this->display(__FILE__, 'menu.tpl');
|
} else {
|
||||||
|
$file = fopen($filename, 'w+');
|
||||||
|
$menus = $this->getTree($cookie->id_lang);
|
||||||
|
fwrite($file, json_encode($menus));
|
||||||
|
fclose($file);
|
||||||
|
}
|
||||||
|
|
||||||
|
$smarty->assign(array(
|
||||||
|
'menus' => $menus
|
||||||
|
));
|
||||||
|
$result = $this->display(__FILE__, 'menu.tpl');
|
||||||
|
}
|
||||||
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function hookPrivateSales_update($params)
|
public function hookPrivateSales_update($params)
|
||||||
{
|
{
|
||||||
|
if (class_exists('CacheRedis')) {
|
||||||
|
CacheRedis::getInstance()->clear('sale_privatesales*');
|
||||||
|
}
|
||||||
$id_langs = array(2,3);
|
$id_langs = array(2,3);
|
||||||
|
|
||||||
foreach ($id_langs as $key => $id_lang) {
|
foreach ($id_langs as $key => $id_lang) {
|
||||||
$filename = _PS_ROOT_DIR_.'/modules/privatesales_family_menu/menu_'.$id_lang.'.txt';
|
$filename = _PS_ROOT_DIR_.'/modules/privatesales_family_menu/menu_'.$id_lang.'.txt';
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user