caching menu
This commit is contained in:
parent
b443abd67c
commit
d0c298f20b
@ -406,11 +406,11 @@ class PrivateSales extends Module {
|
||||
|
||||
$display_limit = Configuration::get('PRIVATESALES_FUTURELIMIT');
|
||||
|
||||
$sales = Sale::getSales(TRUE, NULL, NULL, 'current', FALSE, Configuration::get('PRIVATESALES_SHOW_PUBLIC'), '`position` DESC', NULL, NULL, $site_version_front,TRUE);
|
||||
$sales = Sale::getSales(TRUE, NULL, NULL, 'current', FALSE, Configuration::get('PRIVATESALES_SHOW_PUBLIC'), '`position` DESC', NULL, NULL, $site_version_front, TRUE);
|
||||
if($display_limit == 0) {
|
||||
$futuresales = Sale::getSales(TRUE, NULL, NULL, TRUE, FALSE, Configuration::get('PRIVATESALES_SHOW_PUBLIC'), '`position` ASC', NULL, NULL, $site_version_front,TRUE);
|
||||
$futuresales = Sale::getSales(TRUE, NULL, NULL, TRUE, FALSE, Configuration::get('PRIVATESALES_SHOW_PUBLIC'), '`position` ASC', NULL, NULL, $site_version_front, TRUE);
|
||||
} else {
|
||||
$futuresales = Sale::getSales(TRUE, NULL, NULL, (int) $display_limit, FALSE, Configuration::get('PRIVATESALES_SHOW_PUBLIC'), '`position` ASC', NULL, NULL, $site_version_front,TRUE);
|
||||
$futuresales = Sale::getSales(TRUE, NULL, NULL, (int) $display_limit, FALSE, Configuration::get('PRIVATESALES_SHOW_PUBLIC'), '`position` ASC', NULL, NULL, $site_version_front, TRUE);
|
||||
}
|
||||
|
||||
$smarty->assign(array(
|
||||
@ -439,23 +439,23 @@ class PrivateSales extends Module {
|
||||
}
|
||||
|
||||
public function hookFooter($params) {
|
||||
global $smarty, $cookie;
|
||||
global $smarty, $cookie, $site_version_front;
|
||||
|
||||
$display_limit = Configuration::get('PRIVATESALES_FUTURELIMIT');
|
||||
|
||||
if($cookie->isLogged()) {
|
||||
$sales = Sale::getSales(TRUE, NULL, NULL, 'current', FALSE, Configuration::get('PRIVATESALES_SHOW_PUBLIC'),'`date_end` ASC', NULL, NULL, FALSE, TRUE);
|
||||
$sales = Sale::getSales(TRUE, NULL, NULL, 'current', FALSE, Configuration::get('PRIVATESALES_SHOW_PUBLIC'),'`date_end` ASC', NULL, NULL, $site_version_front, TRUE);
|
||||
if($display_limit == 0) {
|
||||
$futuresales = Sale::getSales(TRUE, NULL, NULL, TRUE, FALSE, Configuration::get('PRIVATESALES_SHOW_PUBLIC'),'`date_end` ASC', NULL, NULL, FALSE, TRUE);
|
||||
$futuresales = Sale::getSales(TRUE, NULL, NULL, TRUE, FALSE, Configuration::get('PRIVATESALES_SHOW_PUBLIC'),'`date_end` ASC', NULL, NULL, $site_version_front, TRUE);
|
||||
} else {
|
||||
$futuresales = Sale::getSales(TRUE, NULL, NULL, (int) $display_limit, FALSE, Configuration::get('PRIVATESALES_SHOW_PUBLIC'),'`date_end` ASC', NULL, NULL, FALSE, TRUE);
|
||||
$futuresales = Sale::getSales(TRUE, NULL, NULL, (int) $display_limit, FALSE, Configuration::get('PRIVATESALES_SHOW_PUBLIC'),'`date_end` ASC', NULL, NULL, $site_version_front, TRUE);
|
||||
}
|
||||
} else {
|
||||
$sales = Sale::getSales(TRUE, TRUE, NULL, 'current', FALSE, Configuration::get('PRIVATESALES_SHOW_PUBLIC'),'`date_end` ASC', NULL, NULL, FALSE, TRUE);
|
||||
$sales = Sale::getSales(TRUE, TRUE, NULL, 'current', FALSE, Configuration::get('PRIVATESALES_SHOW_PUBLIC'),'`date_end` ASC', NULL, NULL, $site_version_front, TRUE);
|
||||
if($display_limit == 0) {
|
||||
$futuresales = Sale::getSales(TRUE, TRUE, NULL, TRUE, FALSE, Configuration::get('PRIVATESALES_SHOW_PUBLIC'),'`date_end` ASC', NULL, NULL, FALSE, TRUE);
|
||||
$futuresales = Sale::getSales(TRUE, TRUE, NULL, TRUE, FALSE, Configuration::get('PRIVATESALES_SHOW_PUBLIC'),'`date_end` ASC', NULL, NULL, $site_version_front, TRUE);
|
||||
} else {
|
||||
$futuresales = Sale::getSales(TRUE, TRUE, NULL, (int) $display_limit, FALSE, Configuration::get('PRIVATESALES_SHOW_PUBLIC'),'`date_end` ASC', NULL, NULL, FALSE, TRUE);
|
||||
$futuresales = Sale::getSales(TRUE, TRUE, NULL, (int) $display_limit, FALSE, Configuration::get('PRIVATESALES_SHOW_PUBLIC'),'`date_end` ASC', NULL, NULL, $site_version_front, TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -18,29 +18,30 @@ class PrivateSales_SaleMenu extends Module {
|
||||
|
||||
return parent::install() && $this->registerHook('top');
|
||||
}
|
||||
|
||||
|
||||
public function hookSubTop($params) {
|
||||
return $this->hookTop($params);
|
||||
}
|
||||
|
||||
public function hookTop($params) {
|
||||
global $cookie, $smarty;
|
||||
global $cookie, $smarty, $site_version_front;
|
||||
|
||||
include_once dirname(__FILE__).'/../privatesales/Sale.php';
|
||||
|
||||
if(_PS_MOBILE_)
|
||||
return false;
|
||||
|
||||
|
||||
/*
|
||||
if($cookie->isLogged()) {
|
||||
*/
|
||||
$sales = Sale::getSales(TRUE, NULL, NULL, 'current', FALSE, Configuration::get('PRIVATESALES_SHOW_PUBLIC'), '`date_start` ASC');
|
||||
|
||||
//$sales = Sale::getSales(TRUE, NULL, NULL, 'current', FALSE, Configuration::get('PRIVATESALES_SHOW_PUBLIC'), '`date_start` ASC');
|
||||
$sales = Sale::getSales(TRUE, NULL, NULL, 'current', FALSE, Configuration::get('PRIVATESALES_SHOW_PUBLIC'), '`position` DESC', NULL, NULL, $site_version_front, TRUE);
|
||||
|
||||
$sales_1 = array();
|
||||
$sales_2 = array();
|
||||
$sales_3 = array();
|
||||
$sale_ids = array();
|
||||
|
||||
|
||||
foreach($sales as $sale) {
|
||||
if($sale->sale_type !== NULL) {
|
||||
if($sale->sale_type == 1) {
|
||||
@ -53,18 +54,23 @@ class PrivateSales_SaleMenu extends Module {
|
||||
}
|
||||
$sale_ids[] = (int) $sale->id;
|
||||
}
|
||||
|
||||
$extra_sale_fields = array();
|
||||
foreach(Db::getInstance()->ExecuteS('
|
||||
|
||||
$query = '
|
||||
SELECT `id_sale`, `value`
|
||||
FROM `'._DB_PREFIX_.'privatesale_extrafield_sale`
|
||||
WHERE `id_sale` IN ('.implode(', ', $sale_ids).')
|
||||
AND `id_lang` = '.(int) $cookie->id_lang.'
|
||||
AND `id_field` = 1
|
||||
') as $row) {
|
||||
$extra_sale_fields[(int) $row['id_sale']] = $row['value'];
|
||||
}
|
||||
|
||||
';
|
||||
|
||||
if (false === ($extra_sale_fields = CacheRedis::getInstance()->getQuery($query, 'sale'))) {
|
||||
$extra_sale_fields = array();
|
||||
foreach(Db::getInstance()->ExecuteS($query) as $row) {
|
||||
$extra_sale_fields[(int) $row['id_sale']] = $row['value'];
|
||||
}
|
||||
CacheRedis::getInstance()->setQuery($query, self::CONTROLLER_NAME, $extra_sale_fields);
|
||||
}
|
||||
|
||||
$smarty->assign(array(
|
||||
'menu_sales' => $sales,
|
||||
'menu_sales_1' => $sales_1,
|
||||
|
Loading…
Reference in New Issue
Block a user