hakeryk2 Posted March 16, 2017 Share Posted March 16, 2017 Hello community Does anyone know how to change order of values in attributes generator to order by name ASC not by id? It is pain in the arsh to look for attribute when generating a bunch of combinations. This is really weird because when You want to add only one combination that the order is sorted by name. Any help will be appreciated. I was looking in \controllers\admin\AdminAttributeGeneratorController.php but I couldn't find any option to simply change. Link to comment Share on other sites More sharing options...
hakeryk2 Posted March 18, 2017 Author Share Posted March 18, 2017 Thanks to @e_com user in this thread I menaged it - the thread is there and You should give like to him https://www.prestashop.com/forums/topic/600159-sortowanie-po-nazwie-cech-w-generatorze-atrybutów-jak-to-wykonać/#entry2525297 Long story short - override getAttributes class with this code in override/classes/Attribute.php <?php class Attribute extends AttributeCore { public static function getAttributes($id_lang, $not_null = false) { if (!Combination::isFeatureActive()) { return array(); } return Db::getInstance()->executeS(' SELECT DISTINCT ag.*, agl.*, a.`id_attribute`, al.`name`, agl.`name` AS `attribute_group` FROM `'._DB_PREFIX_.'attribute_group` ag LEFT JOIN `'._DB_PREFIX_.'attribute_group_lang` agl ON (ag.`id_attribute_group` = agl.`id_attribute_group` AND agl.`id_lang` = '.(int)$id_lang.') LEFT JOIN `'._DB_PREFIX_.'attribute` a ON a.`id_attribute_group` = ag.`id_attribute_group` LEFT JOIN `'._DB_PREFIX_.'attribute_lang` al ON (a.`id_attribute` = al.`id_attribute` AND al.`id_lang` = '.(int)$id_lang.') '.Shop::addSqlAssociation('attribute_group', 'ag').' '.Shop::addSqlAssociation('attribute', 'a').' '.($not_null ? 'WHERE a.`id_attribute` IS NOT NULL AND al.`name` IS NOT NULL AND agl.`id_attribute_group` IS NOT NULL' : '').' ORDER BY agl.`name` ASC, al.`name` ASC '); } } 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