pfs007 Posted June 29, 2015 Share Posted June 29, 2015 (edited) Bonjour, Sous PS 1.6.0.14, j'ai créé un override de frontcontroller.php pour affecter un client à un groupe donné en fonction des bons d'achat qu'il possède. Selon le groupe, le client a donc accès ou non à certains menus complémentaires. Cet override fonctionne très bien, mais nécessite qu'on change de page ou qu'on actualise la page en cours pour que le menu soit correctement présenté. J'ai besoin d'aide pour que le menu ou la page soit rafraîchi automatiquement afin que soient rendus visibles ou pas les menus pour une personne donnée. Voici mon code : class FrontController extends FrontControllerCore { public function init() { parent::init(); $id_customerPFS = $this->context->customer->id; if ($id_customerPFS) { $nb_cart_rule = Db::getInstance()->getValue(' SELECT COUNT(*) FROM `' . _DB_PREFIX_ . 'cart_rule` WHERE `id_customer` = ' . $id_customerPFS . ' AND `quantity` = 1 AND `active` = 1' ); $cartes = Db::getInstance()->executeS(' SELECT * FROM `' . _DB_PREFIX_ . 'cart_rule` WHERE `id_customer` = ' . $id_customerPFS . ' AND `quantity` = 1 AND `active` = 1' ); $customer = new Customer($id_customerPFS); $customer->cleanGroups(); if($nb_cart_rule == 0) { $customer = new Customer($id_customerPFS); $id_special_group = 3; $customer->cleanGroups(); $customer->addGroups(array((int)$id_special_group)); $customer->id_default_group = (int)$id_special_group; $customer->update(); } else { foreach ($cartes as $carte) { $giftcardname = $carte['description']; if (strpos($giftcardname, 'Jardin - 5') !== false){ $id_special_group = 4; $customer->addGroups(array((int)$id_special_group)); $customer->id_default_group = (int)$id_special_group; } if (strpos($giftcardname, 'Jardin - 10') !== false){ $id_special_group = 5; $customer->addGroups(array((int)$id_special_group)); $customer->id_default_group = (int)$id_special_group; } if (strpos($giftcardname, 'Parc - 5') !== false){ $id_special_group = 7; $customer->addGroups(array((int)$id_special_group)); $customer->id_default_group = (int)$id_special_group; } if (strpos($giftcardname, 'Parc - 10') !== false){ $id_special_group = 8; $customer->addGroups(array((int)$id_special_group)); $customer->id_default_group = (int)$id_special_group; } $customer->update(); } } } } } Merci de votre aide. Bonne journée. PFS Edited June 29, 2015 by pfs007 (see edit history) Link to comment Share on other sites More sharing options...
pfs007 Posted July 1, 2015 Author Share Posted July 1, 2015 Bonjour, J'ai cherché, mais je n'ai toujours pas trouvé. Quelqu'un aurait-il une idée ? Merci. PFS Link to comment Share on other sites More sharing options...
pfs007 Posted July 11, 2015 Author Share Posted July 11, 2015 La question est-elle si incongrue, ou la réponse si triviale ? En tout cas, je sèche toujours ! Bon week-end. PFS Link to comment Share on other sites More sharing options...
Mediacom87 Posted July 11, 2015 Share Posted July 11, 2015 Bonjour, Tools::redirect ou un truc dans le genre. 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