Merge branch 'develop' of gitlab.antadis.net:dev-antadis/bebeboutik into develop

This commit is contained in:
Nolwenn J 2017-11-20 18:55:19 +01:00
commit 5be6300e52

View File

@ -24,30 +24,51 @@ class Privatesales_Family_Menu extends Module {
global $cookie, $smarty;
$id_lang = (int)$cookie->id_lang;
$filename = _PS_ROOT_DIR_.'/modules/privatesales_family_menu/menu_'.$id_lang.'.txt';
$expire = time() -3600;
if(file_exists($filename) && filemtime($filename) > $expire) {
$data = file_get_contents($filename);
$menus = json_decode($data, TRUE);
/**
* @Override cache file
*/
if (class_exists('CacheRedis')) {
$tpl_cache_name = 'sale_privatesales_family_menu_'.(int) $cookie->id_lang.'.html';
if (false === ($result = CacheRedis::getInstance()->get($tpl_cache_name, 'privatesales_family_menu'))) {
$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 {
$file = fopen($filename, 'w+');
$menus = $this->getTree($cookie->id_lang);
fwrite($file, json_encode($menus));
fclose($file);
}
$filename = _PS_ROOT_DIR_.'/modules/privatesales_family_menu/menu_'.$id_lang.'.txt';
$expire = time() -3600;
$smarty->assign(array(
'menus' => $menus
));
return $this->display(__FILE__, 'menu.tpl');
if(file_exists($filename) && filemtime($filename) > $expire) {
$data = file_get_contents($filename);
$menus = json_decode($data, TRUE);
} 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)
{
if (class_exists('CacheRedis')) {
CacheRedis::getInstance()->clear('sale_privatesales*');
}
$id_langs = array(2,3);
foreach ($id_langs as $key => $id_lang) {
$filename = _PS_ROOT_DIR_.'/modules/privatesales_family_menu/menu_'.$id_lang.'.txt';
@ -125,8 +146,7 @@ class Privatesales_Family_Menu extends Module {
WHERE p.`public` = 0
AND pv.`version` = "'.pSql($site_version_front).'"
AND p.`enabled` = 1
AND p.`date_start` > NOW()
AND p.`date_end` > NOW()
AND CAST(p.`date_start` AS DATE) = CAST(DATE_ADD(NOW(), INTERVAL 1 DAY) AS DATE)
AND pcf.`id_category_family` = '.(int)$child['id_category_family'].'
GROUP BY p.`id_sale`
ORDER BY p.`date_end` ASC