// blockcategories sql improvements
This commit is contained in:
@@ -172,23 +172,26 @@ class BlockCategories extends Module
|
|||||||
{*/
|
{*/
|
||||||
$maxdepth = Configuration::get('BLOCK_CATEG_MAX_DEPTH');
|
$maxdepth = Configuration::get('BLOCK_CATEG_MAX_DEPTH');
|
||||||
/*p('
|
/*p('
|
||||||
SELECT c.id_parent, c.id_category, cl.name, cl.description, cl.link_rewrite
|
SELECT c.id_parent, c.id_category, cl.name, cl.description, cl.link_rewrite
|
||||||
FROM `'._DB_PREFIX_.'category` c
|
FROM `'._DB_PREFIX_.'category` c
|
||||||
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (c.`id_category` = cl.`id_category` AND cl.`id_lang` = '.$id_lang.Shop::addSqlRestrictionOnLang('cl').')
|
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (c.`id_category` = cl.`id_category` AND cl.`id_lang` = '.$id_lang.Shop::addSqlRestrictionOnLang('cl').')
|
||||||
LEFT JOIN `'._DB_PREFIX_.'category_group` cg ON (cg.`id_category` = c.`id_category`)
|
LEFT JOIN `'._DB_PREFIX_.'category_group` cg ON (cg.`id_category` = c.`id_category`)
|
||||||
LEFT JOIN `'._DB_PREFIX_.'category_shop` cs ON (cs.`id_category` = c.`id_category` AND cs.`id_shop` = '.(int)Context::getContext()->shop->id.')
|
LEFT JOIN `'._DB_PREFIX_.'category_shop` cs ON (cs.`id_category` = c.`id_category`)
|
||||||
WHERE (c.`active` = 1 OR c.`id_category` = 1)
|
WHERE (c.`active` = 1 OR c.`id_category` = '.(int)Configuration::get('PS_HOME_CATEGORY').')
|
||||||
'.((int)($maxdepth) != 0 ? ' AND `level_depth` <= '.(int)($maxdepth) : '').'
|
AND c.`id_category` != '.(int)Configuration::get('PS_ROOT_CATEGORY').'
|
||||||
AND cg.`id_group` IN ('.pSQL($groups).')
|
'.((int)($maxdepth) != 0 ? ' AND `level_depth` <= '.(int)($maxdepth) : '').'
|
||||||
GROUP BY id_category
|
AND cg.`id_group` IN ('.pSQL($groups).')
|
||||||
ORDER BY `level_depth` ASC, '.(Configuration::get('BLOCK_CATEG_SORT') ? 'cl.`name`' : 'c.`position`').' '.(Configuration::get('BLOCK_CATEG_SORT_WAY') ? 'DESC' : 'ASC'));*/
|
AND cs.`id_shop` = '.(int)Context::getContext()->shop->id.'
|
||||||
|
GROUP BY id_category
|
||||||
|
ORDER BY `level_depth` ASC, '.(Configuration::get('BLOCK_CATEG_SORT') ? 'cl.`name`' : 'c.`position`').' '.(Configuration::get('BLOCK_CATEG_SORT_WAY') ? 'DESC' : 'ASC'));*/
|
||||||
if (!$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
|
if (!$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
|
||||||
SELECT c.id_parent, c.id_category, cl.name, cl.description, cl.link_rewrite
|
SELECT c.id_parent, c.id_category, cl.name, cl.description, cl.link_rewrite
|
||||||
FROM `'._DB_PREFIX_.'category` c
|
FROM `'._DB_PREFIX_.'category` c
|
||||||
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (c.`id_category` = cl.`id_category` AND cl.`id_lang` = '.$id_lang.Shop::addSqlRestrictionOnLang('cl').')
|
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (c.`id_category` = cl.`id_category` AND cl.`id_lang` = '.$id_lang.Shop::addSqlRestrictionOnLang('cl').')
|
||||||
LEFT JOIN `'._DB_PREFIX_.'category_group` cg ON (cg.`id_category` = c.`id_category`)
|
LEFT JOIN `'._DB_PREFIX_.'category_group` cg ON (cg.`id_category` = c.`id_category`)
|
||||||
LEFT JOIN `'._DB_PREFIX_.'category_shop` cs ON (cs.`id_category` = c.`id_category`)
|
LEFT JOIN `'._DB_PREFIX_.'category_shop` cs ON (cs.`id_category` = c.`id_category`)
|
||||||
WHERE (c.`active` = 1 OR c.`id_category` = 1)
|
WHERE (c.`active` = 1 OR c.`id_category` = '.(int)Configuration::get('PS_HOME_CATEGORY').')
|
||||||
|
AND c.`id_category` != '.(int)Configuration::get('PS_ROOT_CATEGORY').'
|
||||||
'.((int)($maxdepth) != 0 ? ' AND `level_depth` <= '.(int)($maxdepth) : '').'
|
'.((int)($maxdepth) != 0 ? ' AND `level_depth` <= '.(int)($maxdepth) : '').'
|
||||||
AND cg.`id_group` IN ('.pSQL($groups).')
|
AND cg.`id_group` IN ('.pSQL($groups).')
|
||||||
AND cs.`id_shop` = '.(int)Context::getContext()->shop->id.'
|
AND cs.`id_shop` = '.(int)Context::getContext()->shop->id.'
|
||||||
|
|||||||
Reference in New Issue
Block a user