Serial 3 Posted February 22, 2016 Bonjour, J'ai un bouton sur ma fiche produit dont la balise <a> avec l'attribut "href=" renvoi vers la page d'un autre produit. Ce produit est le même mais avec un "2" devant l'id. Exemple : Le produit 100000 doit renvoyer vers le produit 2100000. J'ai essayé 2-3 manipulations avec la variable $link->getProductLink($product->id) mais je trouve pas Merci ! Share this post Link to post Share on other sites
AG261 3 Posted February 22, 2016 Bonjour, J'ai pas tres bien compris ou tu veux en venir. Mais éventuellement, $newId = '2' . $product->id ; $link->getProductLink( (int)$newId ) ; Pourrait faire l'affaire. Bon dev Share this post Link to post Share on other sites
Serial 3 Posted February 22, 2016 Bonjour, J'ai pas tres bien compris ou tu veux en venir. Mais éventuellement, $newId = '2' . $product->id ; $link->getProductLink( (int)$newId ) ; Pourrait faire l'affaire. Bon dev Merci mais ca ne fonctionne pas. J'ai l'erreur "Invalid product vars". Share this post Link to post Share on other sites
AG261 3 Posted February 22, 2016 Ok, On a alors besoin de plus d'infos : - Es tu sur que le produit "2product_id" existe toujours quelque soit le product_id ? Car pour moi c'est là notre problème actuel. Je te propose donc : $newId = '2' . $product->id ; // voir si le produit existe if ($newproduct = new product( (int)$newId )) { $link->getProductLink( (int)$newId ) ; } else { // faire autre chose } A+ Share this post Link to post Share on other sites
coeos.pro 609 Posted February 22, 2016 Peux tous nous donner un exemple avec le produit "simple" et le produit avec un 2 devant l'id ? Share this post Link to post Share on other sites
Serial 3 Posted February 23, 2016 (edited) L'id de mon produit : 1122661 et mon autre produit : 21122661 Edited February 23, 2016 by Serial (see edit history) Share this post Link to post Share on other sites
coeos.pro 609 Posted February 23, 2016 C'est surtout les URL que je voulais. Si la solution de AG261 ne fonctionne pas c'est qu'il y a autre chose. Share this post Link to post Share on other sites
Serial 3 Posted February 23, 2016 (edited) C'est surtout les URL que je voulais. Si la solution de AG261 ne fonctionne pas c'est qu'il y a autre chose. Je t'es envoyé les liens par message privé. EDIT : J'ai mit l'ID du produit en dur {$link->getProductLink(21122661)} et ca fonctionne. Edited February 23, 2016 by Serial (see edit history) Share this post Link to post Share on other sites
coeos.pro 609 Posted February 23, 2016 tu es en smarty ? j'ai cru que tu étais en php, dans ce cas essaye avec : {$link->getProductLink(2|cat:$id)} Share this post Link to post Share on other sites
Serial 3 Posted February 23, 2016 Oui oui je suis bien en smarty J'ai une erreur avec ton code : ( ! ) Notice: Trying to get property of non-object in C:\wamp\www\PrestaTDU\tools\smarty\sysplugins\smarty_internal_templatebase.php(171) : eval()'d code on line 718 Share this post Link to post Share on other sites
coeos.pro 609 Posted February 23, 2016 tu as mis $id ou $id_product ou $product.id_product ? Share this post Link to post Share on other sites
coeos.pro 609 Posted February 23, 2016 j'ai mis id pour mettre quelque chose, il faut mettre le nom de la variable de l'id de ton produit Share this post Link to post Share on other sites
Serial 3 Posted February 23, 2016 $id comme tu me l'as indiqué. Share this post Link to post Share on other sites
Serial 3 Posted February 23, 2016 Ca fonctionne ! Merci à toi Share this post Link to post Share on other sites