Jump to content

Prestashop 1.7 - Avoir le bon lien produit


Recommended Posts

Bonjour,

J'ai l'énorme malchance de devoir utiliser Prestashop 1.7, et je tombe sur un souci.

Je souhaite (accrochez-vous bien !) récupérer le lien vers un produit.

Voici mon petit bout de code :

     $sql = '
SELECT p.id_product, p.ean13, pl.name, p.id_category_default, pl.link_rewrite, cl.link_rewrite as cat_link_rewrite
FROM `'._DB_PREFIX_.'product` p
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product` AND pl.`id_lang` = '.$id_lang.')
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (p.`id_category_default` = cl.`id_category` AND cl.`id_lang` = '.$id_lang.')
WHERE p.`active`=1
   AND p.id_product'.$operator.intval($this->product->id).'
ORDER BY p.id_product '.$orderway.' LIMIT 1';

     $result = Db::getInstance()->ExecuteS($sql);
     $nextItem = false;
     if (is_array($result) && count($result))
     {
         $row = $result[0];
         $nextItem = Context::getContext()->link->getProductLink((int) $row['id_product'], $row['link_rewrite'], $row['cat_link_rewrite'], $row['ean13']);
     }

Gros souci, ça ne me donne pas le bon lien ... 

Voici le lien que ça me donne (produits de la démo) :

http://127.0.0.1/presta1724/casual-dresses/3-robe-imprimee.html

Qui me conduit vers l'erreur : 

[Debug] This page has moved
Please use the following URL instead: http://127.0.0.1/presta1724/casual-dresses/3-13-robe-imprimee.html

 

Question existentielle ... Comment avoir le bon lien produit ?

Je vous remercie !

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...