Avisos
Vaciar todo

Ocultar una categoría del bloque de categorías sin desactivarla  

 
Luis
 Luis
Estimable Member

Buenas tardes, me gustaría ocultar una de las categorías en el bloque de categorías que aparece a la izquierda en Prestashop pero sin desactivarla, de forma que pueda enlazar a la misma desde otras vías.

He leído en otros foros que lo que hay que incluir es esto: AND c.id_category NOT IN (18) *18 es la categoría que quiero ocultar. ¿Dónde se supone que debo insertarlo?

public function hookLeftColumn($params)
{
$this->setLastVisitedCategory();
$phpself = $this->context->controller->php_self;
$current_allowed_controllers = array('category');

if ($phpself != null && in_array($phpself, $current_allowed_controllers) && Configuration::get('BLOCK_CATEG_ROOT_CATEGORY') && isset($this->context->cookie->last_visited_category) && $this->context->cookie->last_visited_category)
{
$category = new Category($this->context->cookie->last_visited_category, $this->context->language->id);
if (Configuration::get('BLOCK_CATEG_ROOT_CATEGORY') == 2 && !$category->is_root_category && $category->id_parent)
$category = new Category($category->id_parent, $this->context->language->id);
elseif (Configuration::get('BLOCK_CATEG_ROOT_CATEGORY') == 3 && !$category->is_root_category && !$category->getSubCategories($category->id, true))
$category = new Category($category->id_parent, $this->context->language->id);
}
else
$category = new Category((int)Configuration::get('PS_HOME_CATEGORY'), $this->context->language->id);

$cacheId = $this->getCacheId($category ? $category->id : null);

if (!$this->isCached('blockcategories.tpl', $cacheId))
{
$range = '';
$maxdepth = Configuration::get('BLOCK_CATEG_MAX_DEPTH');
if (Validate::isLoadedObject($category))
{
if ($maxdepth > 0)
$maxdepth += $category->level_depth;
$range = 'AND nleft >= '.(int)$category->nleft.' AND nright nright;
}

$resultIds = array();
$resultParents = array();
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
SELECT c.id_parent, c.id_category, cl.name, cl.description, cl.link_rewrite
FROM `'._DB_PREFIX_.'category` c
INNER JOIN `'._DB_PREFIX_.'category_lang` cl ON (c.`id_category` = cl.`id_category` AND cl.`id_lang` = '.(int)$this->context->language->id.Shop::addSqlRestrictionOnLang('cl').')
INNER JOIN `'._DB_PREFIX_.'category_shop` cs ON (cs.`id_category` = c.`id_category` AND cs.`id_shop` = '.(int)$this->context->shop->id.')
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` context->customer->id))).')
)
ORDER BY `level_depth` ASC, '.(Configuration::get('BLOCK_CATEG_SORT') ? 'cl.`name`' : 'cs.`position`').' '.(Configuration::get('BLOCK_CATEG_SORT_WAY') ? 'DESC' : 'ASC'));
foreach ($result as &$row)
{
$resultParents[$row['id_parent']][] = &$row;
$resultIds[$row['id_category']] = &$row;
}

$blockCategTree = $this->getTree($resultParents, $resultIds, $maxdepth, ($category ? $category->id : null));
$this->smarty->assign('blockCategTree', $blockCategTree);

if ((Tools::getValue('id_product') || Tools::getValue('id_category')) && isset($this->context->cookie->last_visited_category) && $this->context->cookie->last_visited_category)
{
$category = new Category($this->context->cookie->last_visited_category, $this->context->language->id);
if (Validate::isLoadedObject($category))
$this->smarty->assign(array('currentCategory' => $category, 'currentCategoryId' => $category->id));
}

$this->smarty->assign('isDhtml', Configuration::get('BLOCK_CATEG_DHTML'));
if (file_exists(_PS_THEME_DIR_.'modules/blockcategories/blockcategories.tpl'))
$this->smarty->assign('branche_tpl_path', _PS_THEME_DIR_.'modules/blockcategories/category-tree-branch.tpl');
else
$this->smarty->assign('branche_tpl_path', _PS_MODULE_DIR_.'blockcategories/category-tree-branch.tpl');
}
return $this->display(__FILE__, 'blockcategories.tpl', $cacheId);
}

URL del sitio: Contenido solo visible a usuarios registrados

Citar
Respondido : 16/06/2015 2:50 pm
Pablo Velasco
 Pablo Velasco
Illustrious Member

Hola,

Lo tendrías que insertar en el select que hay en el código. En concreto, te tendría que quedar así:

$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
SELECT c.id_parent, c.id_category, cl.name, cl.description, cl.link_rewrite
FROM `'._DB_PREFIX_.'category` c
INNER JOIN `'._DB_PREFIX_.'category_lang` cl ON (c.`id_category` = cl.`id_category` AND cl.`id_lang` = '.(int)$this->context->language->id.Shop::addSqlRestrictionOnLang('cl').')
INNER JOIN `'._DB_PREFIX_.'category_shop` cs ON (cs.`id_category` = c.`id_category` AND cs.`id_shop` = '.(int)$this->context->shop->id.')
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` context->customer->id))).')
) AND c.id_category NOT IN (18) 
ORDER BY `level_depth` ASC, '.(Configuration::get('BLOCK_CATEG_SORT') ? 'cl.`name`' : 'cs.`position`').' '.(Configuration::get('BLOCK_CATEG_SORT_WAY') ? 'DESC' : 'ASC'));

cambiando el 18 por el id de categoría que quieres ocultar.

Recuerda hacer una copia de seguridad de este archivo antes de modificarlo, por si se producen errores tras el cambio.

ResponderCitar
Respondido : 16/06/2015 3:15 pm

optimiza-automaticamente-todas-las-imagenes-de-tu-wordpress

Luis
 Luis
Estimable Member

Perfectísimo, mil gracias!

ResponderCitar
Respondido : 17/06/2015 5:14 pm
Julen
 Julen
Miembro Admin

Gracias por tu confianza 🙂

Nos alegra que te guste nuestro servicio. 🙂

Nos sería de mucha utilidad que nos dejases tu testimonio, solicitamos testimonios para colocar en nuestra página y ayudar a otros posibles clientes a decidirse por nuestros servicios:

Puedes crear el testimonio aquí: https://www.webempresa.com/testimonios.html?view=form&layout=edit

Si nos quieres enviar tu experiencia con nuestro servicio, la publicaremos en nuestra página con un link hacia tu Web. Nuestro dominio webempresa.com tiene una autoridad alta, así que el link siempre te ayudará en el posicionamiento en buscadores de tu Web.

Si ya lo solicitamos anteriormente y nos lo facilitaste, puedes dejar otro testimonio si tienes otra página que quieras posicionar mejor al tener un link en la nuestra con tu testimonio.

Gracias por publicar tu testimonio y por tus palabras de agradecimiento.

ResponderCitar
Respondido : 17/06/2015 5:45 pm

Luis
 Luis
Estimable Member

Claro, dejaré un testimonio sobre vuestro gran trabajo .

Quería comentaros una cosa acerca de este mismo asunto que a lo mejor ayuda a más gente, si queremos ocultar más categorías, lo correcto sería hacerlo así? * Por ejemplo dos más con las ID "25" y "56"

AND c.id_category NOT IN (18,25,56)

Gracias.

ResponderCitar
Respondido : 25/06/2015 11:36 am