abhisek Posted September 24, 2013 Share Posted September 24, 2013 (edited) Hello all, How can I hide the home category? I want to display all categories, except the home category which is a root category. Since it's a root category, I can't delete it. Even if I delete, I need to make changes to child categories. Any help is appreciated. Edited September 24, 2013 by abhisek (see edit history) Link to comment Share on other sites More sharing options...
PascalVG Posted September 24, 2013 Share Posted September 24, 2013 Where do you want to hide it? In block categories? In Back office? please elaborate... pascal Link to comment Share on other sites More sharing options...
abhisek Posted September 24, 2013 Author Share Posted September 24, 2013 Thank you for the quick response. Yes, on blockcategories and on a custom module that I am developing. Link to comment Share on other sites More sharing options...
PascalVG Posted September 24, 2013 Share Posted September 24, 2013 You can check if $level_depth > 1 (if you have $category, use: $category->level_depth ) (from classes/Category.php: ) /** @var integer Parents number */ public $level_depth; Root = level_depth 0 Home = level_depth 1 Hope this helps, pascal Link to comment Share on other sites More sharing options...
abhisek Posted September 24, 2013 Author Share Posted September 24, 2013 (edited) Thanks, Pascal. It's of much help. However, I spent some time with classes/Category.php and there seems to be no existing function that serves the purpose. So, I made a custom sql inside a function ($id_lang is a parameter of the function OR we can use $this->context->language->id): $q = 'SELECT c.`id_category`, cl.`name`, cl.`link_rewrite` FROM `'._DB_PREFIX_.'category` c LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (c.`id_category` = cl.`id_category`'.Shop::addSqlRestrictionOnLang('cl').') '.Shop::addSqlAssociation('category', 'c').' WHERE cl.`id_lang` = '.(int)$id_lang.' AND c.`id_category` != '.Configuration::get('PS_ROOT_CATEGORY').' AND c.`level_depth` > 1 GROUP BY c.id_category ORDER BY c.`id_category`, category_shop.`position`'; Edited September 24, 2013 by abhisek (see edit history) Link to comment Share on other sites More sharing options...
PascalVG Posted September 24, 2013 Share Posted September 24, 2013 N.B. Don't forget to check if ps_category.active = 1 ! Link to comment Share on other sites More sharing options...
abhisek Posted September 25, 2013 Author Share Posted September 25, 2013 Damn, I missed that. Thanks! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now