Jump to content

recupere id grand parent categorie


Recommended Posts

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

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 by doekia (see edit history)
Link to comment
Share on other sites

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

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.

  • Like 1
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...