rahim Posted May 4, 2009 Share Posted May 4, 2009 bonjour, est ce que je peux mettre le tri du moins cher par défaut?merci Link to comment Share on other sites More sharing options...
Mambe Posted May 5, 2009 Share Posted May 5, 2009 Bonjour,Afin de mettre des tri par défaut, il faut je pense, définir les variables 'orderby' et 'orderway', soit quand tu arrive sur la page désirée soit lorsque tu appelle la page désiré. Link to comment Share on other sites More sharing options...
rahim Posted May 5, 2009 Author Share Posted May 5, 2009 dans la page ou on affiche la liste des produits il y'a une liste de tri (ordre alphabétique ordre du moin cher...) je veux que l'ordre du moins cher soit mi par défaut comment je fait. Link to comment Share on other sites More sharing options...
Mambe Posted May 5, 2009 Share Posted May 5, 2009 Re,Une solution pour ton soucis : Dans le fichier product-sort.php : if (empty($orderBy) || $orderBy == 'position') { $orderBy = 'price'; $orderWay = 'ASC'; } Morceau de code à ajouter avant $smarty->assign(array( 'orderby' => $orderBy, 'orderway' => $orderWay )); Par contre avec cette methode, le filtre '---' ne fonctionne plus.Je pense qu'il y a une methode plus propre, je chercherais des que j ai plus de temps. Link to comment Share on other sites More sharing options...
rahim Posted May 5, 2009 Author Share Posted May 5, 2009 merci pour l'info mais malheureusement ca na pas marché (( Link to comment Share on other sites More sharing options...
rahim Posted May 5, 2009 Author Share Posted May 5, 2009 $stock_management = intval(Configuration::get('PS_STOCK_MANAGEMENT')) ? true : false; // no display quantity order if stock management disabled$orderByValues = array(0 => 'name', 1 => 'price', 2 => 'date_add', 3 => 'date_upd', 4 => 'position', 5 => 'manufacturer_name', 6 => 'quantity');$orderWayValues = array(0 => 'ASC', 1 => 'DESC');$orderBy = Tools::strtolower(Tools::getValue('orderby', $orderByValues[intval(Configuration::get('PS_PRODUCTS_ORDER_BY'))]));$orderWay = Tools::strtoupper(Tools::getValue('orderway', $orderWayValues[intval(Configuration::get('PS_PRODUCTS_ORDER_WAY'))]));if (!in_array($orderBy, $orderByValues)) $orderBy = $orderByValues[0];if (!in_array($orderWay, $orderWayValues)) $orderWay = $orderWayValues[0];$smarty->assign(array( 'orderby' => $orderBy, 'orderway' => $orderWay, 'stock_management' => $stock_management));alors je rajoute le bout de code que tu m'as donné sans rien supprimé?? si c lele cas c ce que j'ai fait et ca n'a pa marché.( Link to comment Share on other sites More sharing options...
Mambe Posted May 6, 2009 Share Posted May 6, 2009 C'est ça, ce qui donne : $stock_management = intval(Configuration::get(‘PS_STOCK_MANAGEMENT’)) ? true : false; // no display quantity order if stock management disabled$orderByValues = array(0 => ‘name’, 1 => ‘price’, 2 => ‘date_add’, 3 => ‘date_upd’, 4 => ‘position’, 5 => ‘manufacturer_name’, 6 => ‘quantity’);$orderWayValues = array(0 => ‘ASC’, 1 => ‘DESC’);$orderBy = Tools::strtolower(Tools::getValue(‘orderby’, $orderByValues[intval(Configuration::get(‘PS_PRODUCTS_ORDER_BY’))]));$orderWay = Tools::strtoupper(Tools::getValue(‘orderway’, $orderWayValues[intval(Configuration::get(‘PS_PRODUCTS_ORDER_WAY’))]));if (!in_array($orderBy, $orderByValues)) $orderBy = $orderByValues[0];if (!in_array($orderWay, $orderWayValues)) $orderWay = $orderWayValues[0];if (empty($orderBy) || $orderBy == 'position'){ $orderBy = 'price'; $orderWay = 'ASC';} $smarty->assign(array( ‘orderby’ => $orderBy, ‘orderway’ => $orderWay, ‘stock_management’ => $stock_management));Gaffe à bien remettre les crochets autour du petit zéro rouge que tu as à l'affichage du forum Link to comment Share on other sites More sharing options...
rahim Posted May 6, 2009 Author Share Posted May 6, 2009 ca march pas il maffiche encor le meme tri par defaut -- Link to comment Share on other sites More sharing options...
Mambe Posted May 6, 2009 Share Posted May 6, 2009 Alors, fait un 'echo' de tes variables $orderBy et $orderWay pour connaitre les valeurs quelles prennent.Ainsi tu pourras adapter ta condition 'if' . Link to comment Share on other sites More sharing options...
rahim Posted May 6, 2009 Author Share Posted May 6, 2009 bizar meme avec l'echo y'a rien Link to comment Share on other sites More sharing options...
Mambe Posted May 6, 2009 Share Posted May 6, 2009 Hmmmm, les varaibles $orderBy et $orderWay sont vides ?As-tu bien fait l'echo juste avant le '$smarty->assign' ?Si elles sont vides, la condition if(empty($orderBy)) devrait être juste. Link to comment Share on other sites More sharing options...
rahim Posted May 7, 2009 Author Share Posted May 7, 2009 bonjour,quand j'ai fait l'echo avant le $smarty....il m'affich : date_addASC Link to comment Share on other sites More sharing options...
Mambe Posted May 7, 2009 Share Posted May 7, 2009 Re, Alors met avant le $smarty ... : if (empty($orderBy) || $orderBy == ‘date_add’){$orderBy = ‘price’; $orderWay = ‘ASC’;} Link to comment Share on other sites More sharing options...
rahim Posted May 7, 2009 Author Share Posted May 7, 2009 meme probléme aparamen il n'entre pas dans la condition :if (empty($orderBy) || $orderBy == ‘date_add’) Link to comment Share on other sites More sharing options...
rahim Posted May 7, 2009 Author Share Posted May 7, 2009 ca a marché ms y'avai un pb avec les cotes donc le code juste c'est:if (empty($orderBy) || $orderBy == 'date_add'){$orderBy = 'price';$orderWay = 'ASC';} Link to comment Share on other sites More sharing options...
rahim Posted May 7, 2009 Author Share Posted May 7, 2009 merci pour ton aide ))))) Link to comment Share on other sites More sharing options...
Cédric Girard Posted October 14, 2009 Share Posted October 14, 2009 BonjourJe remonte ce fil car... j'ai cherché car un client me le demandait et en fait le tri par défaut des produits est paramétrable dans les préférences de la boutique Juste pour info (parfois il ne faut pas chercher la complication ) 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