ZonTavE Posted October 18, 2008 Share Posted October 18, 2008 Salut out le monde,petite question, comment est-ce que je pourrais faire en sorte que l'affichage des fabricant dans le module fabricant soit affiché dans un ordre aléatoire et nom dans l'ordre alphabetique? Merci beaucoup d'avance ;-)Topic déplacé -yoya971 Link to comment Share on other sites More sharing options...
Dale Cooper Posted October 19, 2008 Share Posted October 19, 2008 Hello,voilà ce que j'ai fait pour obtenir ce résultat :dans classes/Manufacturer.php , ligne 127 j'ai remplacé $sql.= ' ORDER BY m.`name` ASC'; par $sql.= ' ORDER BY RAND()'; that's all Link to comment Share on other sites More sharing options...
ZonTavE Posted October 20, 2008 Author Share Posted October 20, 2008 Super merci vraiment beaucoup. Link to comment Share on other sites More sharing options...
olivierl Posted February 18, 2010 Share Posted February 18, 2010 J'ajoute une question : est-il possible de choisir l'ordre d'affichage des fabricants comme on peut le faire pour les catégories (01.Catégorie name) ?Merci ! Link to comment Share on other sites More sharing options...
labutte Posted June 25, 2010 Share Posted June 25, 2010 Bonjour,@olivierl : je cherche aussi à choisir l'ordre d'ffichage des fabricants. Quelqu'un a déjà posté une solution dans ce post : http://www.prestashop.com/forums/viewthread/10155/modules_tiers/ajouter_une_colonne_ordre_au_fabriquantMalheureusement je n'ai pas réussi à faire fonctionner cette modif...J'ai ajouté la fonction hideManufacturerPosition($name) puis modifié getNameById($id_manufacturer) mais sans succès.Je suis sur 1.3.1Quelqu'un a-t-il déjà essayé? Link to comment Share on other sites More sharing options...
matt Posted February 16, 2011 Share Posted February 16, 2011 Merci !!Sinon mettre $sql.= ' ORDER BY m.`id_manufacturer` ASC'.($p ? ' LIMIT '.((intval($p) - 1) * intval($n)).','.intval($n) : ''); si vous vous classer par ordre d'ID 1 Link to comment Share on other sites More sharing options...
anne4113 Posted March 21, 2011 Share Posted March 21, 2011 Ca c'est super mais comment fait-on ensuite pour changer l'ordre des identifiants ? Et puis tant que j'y suis, comment fait-on pour laisser par ordre alphabétique dans la liste déroulante ? Link to comment Share on other sites More sharing options...
toto37 Posted September 9, 2011 Share Posted September 9, 2011 Sur version 1.4.3 Pour la liste déroulante, je l'ai supprimé et à la place j'ai rajouté un lien "voir tous les fabriquants" (je sais que ça fait redondance avec le H4, mais le premier est plus un titre de rubrique) Sinon, pour faire propre y'a moyen d'extend la classe dans le repertoire override, explication : Dans module>blockmanufacturer>blockmanufacturer.php Remplacer $smarty->assign(array( 'manufacturers' => Manufacturer::getManufacturers(), par $smarty->assign(array( 'manufacturers' => Manufacturer::getManufacturersRand(), Puis créer dans le repertoire override>classes un fichier Manufacturer.php, et y mettre ce code : <?php class Manufacturer extends ManufacturerCore { public $id; /** @var integer manufacturer ID */ public $id_manufacturer;//FIXME is it really usefull...? /** @var string Name */ public $name; /** @var string A description */ public $description; /** @var string A short description */ public $short_description; /** @var int Address */ public $id_address; /** @var string Object creation date */ public $date_add; /** @var string Object last modification date */ public $date_upd; /** @var string Friendly URL */ public $link_rewrite; /** @var string Meta title */ public $meta_title; /** @var string Meta keywords */ public $meta_keywords; /** @var string Meta description */ public $meta_description; /** @var boolean active */ public $active; protected $fieldsRequired = array('name'); protected $fieldsSize = array('name' => 64); protected $fieldsValidate = array('name' => 'isCatalogName'); protected $fieldsSizeLang = array('short_description' => 254, 'meta_title' => 128, 'meta_description' => 255, 'meta_description' => 255); protected $fieldsValidateLang = array('description' => 'isString', 'short_description' => 'isString', 'meta_title' => 'isGenericName', 'meta_description' => 'isGenericName', 'meta_keywords' => 'isGenericName'); protected $table = 'manufacturer'; protected $identifier = 'id_manufacturer'; protected $webserviceParameters = array( 'fields' => array( 'link_rewrite' => array('getter' => 'getLink', 'setter' => false), ), 'associations' => array( 'addresses' => array('resource' => 'address', 'setter' => false, 'fields' => array( 'id' => array('xlink_resource' => 'addresses'), )), ), ); static public function getManufacturersRand($getNbProducts = false, $id_lang = 0, $active = true, $p = false, $n = false, $all_group = false) { if (!$id_lang) $id_lang = (int)Configuration::get('PS_LANG_DEFAULT'); $sql = 'SELECT m.*, ml.`description`'; $sql.= ' FROM `'._DB_PREFIX_.'manufacturer` m LEFT JOIN `'._DB_PREFIX_.'manufacturer_lang` ml ON (m.`id_manufacturer` = ml.`id_manufacturer` AND ml.`id_lang` = '.(int)($id_lang).') '.($active ? ' WHERE m.`active` = 1' : ''); //$sql.= ' ORDER BY m.`name` ASC'.($p ? ' LIMIT '.(((int)($p) - 1) * (int)($n)).','.(int)($n) : ''); $sql.= ' ORDER BY RAND()'; $manufacturers = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS($sql); if ($manufacturers === false) return false; if ($getNbProducts) { $sqlGroups = ''; if (!$all_group) { $groups = FrontController::getCurrentCustomerGroups(); $sqlGroups = (count($groups) ? 'IN ('.implode(',', $groups).')' : '= 1'); } foreach ($manufacturers as $key => $manufacturer) { $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('SELECT p.`id_product` FROM `'._DB_PREFIX_.'product` p LEFT JOIN `'._DB_PREFIX_.'manufacturer` as m ON (m.`id_manufacturer`= p.`id_manufacturer`) WHERE m.`id_manufacturer` = '.(int)($manufacturer['id_manufacturer']). ($active ? ' AND p.`active` = 1 ' : ''). ($all_group ? '' : ' AND p.`id_product` IN ( SELECT cp.`id_product` FROM `'._DB_PREFIX_.'category_group` cg LEFT JOIN `'._DB_PREFIX_.'category_product` cp ON (cp.`id_category` = cg.`id_category`) WHERE cg.`id_group` '.$sqlGroups.')')); $manufacturers[$key]['nb_products'] = sizeof($result); } } for ($i = 0; $i < sizeof($manufacturers); $i++) if ((int)(Configuration::get('PS_REWRITING_SETTINGS'))) $manufacturers[$i]['link_rewrite'] = Tools::link_rewrite($manufacturers[$i]['name'], false); else $manufacturers[$i]['link_rewrite'] = 0; return $manufacturers; } } Il vous reste plus qu'à choisir le nombre de fabricants a afficher dans backoffice ^^ Personnellement, je compte transformer ces fabricants en logo, histoire d'avoir un peu un affichage type facebook des fabricants Link to comment Share on other sites More sharing options...
daftfunk Posted May 9, 2012 Share Posted May 9, 2012 est ce possible d'avoir les logo en random et la liste en alphabétique? 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