pixAN Posted March 15, 2018 Share Posted March 15, 2018 Bonjour, Je sougaire pouvoir récupérer l'id du grand parent d'un catégorie. Ex : CAT 1 - CAT 1.1 -- CAT 1.11 Avec $categories->id_parent, je récupére l'ID de CAT 1.1 mais je voudrais l'ID de CAT 1 Est-ce possible? Merci Link to comment Share on other sites More sharing options...
doekia Posted March 15, 2018 Share Posted March 15, 2018 (edited) Dans quel lieu te trouves-tu au moment de savoir ça? tpl? php? quelle est ta version? Est-ce vraiment le grand-parent ou le plus vieil ancêtre que tu cherches? (CAT 1.1.1.1 => CAT 1 vs CAT 1.1.1.1 => CAT 1.1) ? Un jour il faudra quand même que les gens apprennent à poser des questions avec un minimum d'information pour ceux qui veulent répondre. Edited March 15, 2018 by doekia (see edit history) Link to comment Share on other sites More sharing options...
Eolia Posted March 15, 2018 Share Posted March 15, 2018 Je pense qu'il est chez lui... Link to comment Share on other sites More sharing options...
doekia Posted March 15, 2018 Share Posted March 15, 2018 Water closet Link to comment Share on other sites More sharing options...
pixAN Posted March 15, 2018 Author Share Posted March 15, 2018 oui je suis bien chez moi! C'est dans un fichier php J'utilise prestashop 1.6 et c'est bien le grand parent que je recherche . Merci pour votre aide Link to comment Share on other sites More sharing options...
pixAN Posted March 15, 2018 Author Share Posted March 15, 2018 voici mon code : obj_cat = new Category(null, null, $this->_idShop); $obj_cat->name = $this->_createMultiLangField( $cat, $obj_cat->name ); $obj_cat->link_rewrite = $this->_createMultiLangField( Tools::link_rewrite( $cat ), $obj_cat->link_rewrite ); $obj_cat->id_parent = $parent_cat; if($parent_cat ==5415){ $obj_cat->active = 0; } et je voudrais dire if grand parent== 5415 Link to comment Share on other sites More sharing options...
Eolia Posted March 15, 2018 Share Posted March 15, 2018 grand-papa est dans son fauteuil, à gauche derrière vous Link to comment Share on other sites More sharing options...
pixAN Posted March 15, 2018 Author Share Posted March 15, 2018 Malheureusement non. Link to comment Share on other sites More sharing options...
doekia Posted March 15, 2018 Share Posted March 15, 2018 1/ $parent = new Category($category->id_parent); if ($parent->id_parent == 5415) { traitement } 2/ select id_parent from ps_category c inner join ps_category c2 on c2.id_category = c.id_parent where c.id_category = $category->id_parent 3/ select id_category from ps_category where nleft < $category->nleft and nright > $category->nright and level = $category->level - 2 4/ ... Tellement de méthode que j'ai la flegme de toute les lister. 1 Link to comment Share on other sites More sharing options...
pixAN Posted March 16, 2018 Author Share Posted March 16, 2018 Merci beaucoup, ca suffira amplement. 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