Paolo Bru Posted July 18, 2013 Share Posted July 18, 2013 Hi in my shop I have 4 levels of depth of the categories. When you are in a category of level 4 I would like to know who is the category of Level 2 The parameter id_parent know the higher category, but how do I know that the level 2? I have to use this information in the file category.tpl thanks Link to comment Share on other sites More sharing options...
Paolo Bru Posted July 19, 2013 Author Share Posted July 19, 2013 Any idea? Link to comment Share on other sites More sharing options...
NemoPS Posted July 20, 2013 Share Posted July 20, 2013 You mean you want to display the grandfather of category level 4? Link to comment Share on other sites More sharing options...
Paolo Bru Posted July 25, 2013 Author Share Posted July 25, 2013 You mean you want to display the grandfather of category level 4? Thanks for the replay I have this structure - category one ---->sub-category alpha =====>sub sub-category beta - category two - category Three - category four when I'm in the sub-category alpha, I know the information of the category one through parameter id_parent. When you are in the sub sub-category beta, how do I know the information of the category one? Link to comment Share on other sites More sharing options...
NemoPS Posted July 25, 2013 Share Posted July 25, 2013 I would go for a module, and use this query 'SELECT id_parent from ps_category WHERE id_category = ' . $current_id_parent Where of course the variable is the $id_parent of the current category. You should create a new hook in the category, this way http://nemops.com/adding-hooks-to-prestashop-1-5/ Then you can either pass a variable to the hook, or grab the current category id like $id_category = Tools::getValue('id_category'); Of course, to get the parent use $category = new Category($id_category) and then $category->parent Link to comment Share on other sites More sharing options...
Paolo Bru Posted July 25, 2013 Author Share Posted July 25, 2013 Perfect, thanks Link to comment Share on other sites More sharing options...
vekia Posted July 25, 2013 Share Posted July 25, 2013 hello thanks for the solution im going to mark this thread as solved I also changed the tittle to point the main case here regards Link to comment Share on other sites More sharing options...
Recommended Posts