mdelteil Posted November 18, 2013 Share Posted November 18, 2013 Bonjour, Lorsque l'admin créé un nouveau produit, je déclenche une fonction, grâce au hook ActionProductAdd.Celui ci retourne une variable ($params) que je renvoie à ma fonction.Jusque là tout va bien.Mais je ne sais pas comment accéder aux informations de cette variable $params (j'avoue que sorti des classes, en php objet, je suis un peu nul). public function hookActionProductAdd($params) { $this->params = $params; if (!$this->createItm($this->params, 'A')) return false; return; } public function createItm($params, $action) { $this->params = $params; $this->action = $action; var_dump($this->params); // etc... } Le var_dump me donne (pour le début...) : array 'product' => object(Product)[33] public 'tax_name' => null public 'tax_rate' => null public 'id_manufacturer' => string '0' (length=1) public 'id_supplier' => string '0' (length=1) public 'id_category_default' => string '3' (length=1) Comment puis-je accéder dans ma fonction createItm() à la valeur de 'id_category_default' par exemple ? Link to comment Share on other sites More sharing options...
coeos.pro Posted November 18, 2013 Share Posted November 18, 2013 $this->params = $params;et $this->action = $action;sont inutiles (à priori) essaye : public function hookActionProductAdd($params) { if (!$this->createItm($params, 'A')) return false; return True; } public function createItm($params, $action) { $id_category_default = (int)$params['id_category_default']; // etc... } pour hookActionProductAdd met return True; sinon tu peux avoir du mal de faire la différence en false et true. Link to comment Share on other sites More sharing options...
mdelteil Posted November 18, 2013 Author Share Posted November 18, 2013 Hééé non. J'avais déjà essayé... ça retourne une erreur :Notice: Undefined index: id_category_default in xxxxxx.php on line 60 produit est associé à un Objet Produit. C'est cet Objet intermédiaire qui me pose problème. Link to comment Share on other sites More sharing options...
coeos.pro Posted November 18, 2013 Share Posted November 18, 2013 autant pour moi j'avais pas vu product, essaye avec : $id_category_default = (int)$params['product']['id_category_default']; Link to comment Share on other sites More sharing options...
mdelteil Posted November 18, 2013 Author Share Posted November 18, 2013 Non plus.et $id_category_default = (int)$params->product['id_category_default']; non plus Link to comment Share on other sites More sharing options...
coeos.pro Posted November 18, 2013 Share Posted November 18, 2013 et (int)$params['product']->id_category_default; 1 Link to comment Share on other sites More sharing options...
mdelteil Posted November 18, 2013 Author Share Posted November 18, 2013 OUI !!!! MERCI ! Link to comment Share on other sites More sharing options...
coeos.pro Posted November 18, 2013 Share Posted November 18, 2013 c'est dur le lundi... j'vais aller prendre mon café 1 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