linkweb Posted February 20, 2015 Share Posted February 20, 2015 Bonjour, J'utilise prestashop 1.5 et j'aimerai modifier l'ordre d'affichage de certaines catégories. En effet, je viens de modifier dans le fichier classes/Category.php le ORDER BY pour pouvoir enfin voir mes nouvelles catégories apparaître en haut et non en bas à la suite pour mettre en avant les nouvelles collections de produits. Problème : ça a changé l'ordre partout alors qu'ailleurs le tri par ordre alphabétique est beaucoup mieux approprié. j'ai donc trouvé dans le fichier Category.php la ligne qui permet de spécifier le ORDER BY, mais je ne trouve pas comment indiquer un order by spécifique en fonction de l'ID de la catégorie affiché dans l'URL. J'ai beau testé avec par exemple (c'est grossier mais bon) : if ($id_parent == 288) { $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(' SELECT c.*, cl.id_lang, cl.name, cl.description, cl.link_rewrite, cl.meta_title, cl.meta_keywords, cl.meta_description FROM `'._DB_PREFIX_.'category` c '.Shop::addSqlAssociation('category', 'c').' LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (c.`id_category` = cl.`id_category` AND `id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('cl').') LEFT JOIN `'._DB_PREFIX_.'category_group` cg ON (cg.`id_category` = c.`id_category`) WHERE `id_parent` = '.(int)$this->id.' '.($active ? 'AND `active` = 1' : '').' AND cg.`id_group` '.$sql_groups.' GROUP BY c.`id_category` ORDER BY `level_depth` DESC, category_shop.`position` DESC '); } else { $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(' SELECT c.*, cl.id_lang, cl.name, cl.description, cl.link_rewrite, cl.meta_title, cl.meta_keywords, cl.meta_description FROM `'._DB_PREFIX_.'category` c '.Shop::addSqlAssociation('category', 'c').' LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (c.`id_category` = cl.`id_category` AND `id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('cl').') LEFT JOIN `'._DB_PREFIX_.'category_group` cg ON (cg.`id_category` = c.`id_category`) WHERE `id_parent` = '.(int)$this->id.' '.($active ? 'AND `active` = 1' : '').' AND cg.`id_group` '.$sql_groups.' GROUP BY c.`id_category` ORDER BY `name` ASC, category_shop.`position` ASC '); } Ca ne fonctionne pas. Merci d'avance pour votre aide ! Link to comment Share on other sites More sharing options...
linkweb Posted March 2, 2015 Author Share Posted March 2, 2015 Bonjour, Je n'ai à ce jour trouvé aucune solution, si quelqu'un de plus expérimenté passe par là, je vous serais très reconnaissant Merci. 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