logz05 Posted December 28, 2012 Share Posted December 28, 2012 Hi, In the old Prestashop (1.4) Attribute groups were collapsed in the attribute generator. In 1.5.2 they all show. How can we change this so that they are collapsed? Thanks Link to comment Share on other sites More sharing options...
logz05 Posted January 3, 2013 Author Share Posted January 3, 2013 (edited) Aswered my own question change code starting at line 63 of admin/themes/default/template/controllers/attribute_generator/content.tpl to: <optgroup onclick="target=getE('group_{$attribute_group['id_attribute_group']}');toggle(target,target.style.display == 'none');" name="title_{$attribute_group['id_attribute_group']}" id="group_title_{$attribute_group['id_attribute_group']}" label="{$attribute_group['name']|escape:'htmlall':'UTF-8'}"> <optgroup style="display: none;" name="{$attribute_group['id_attribute_group']}" id="group_{$attribute_group['id_attribute_group']}" label=""> {foreach $attribute_js[$attribute_group['id_attribute_group']] as $k => $v} <option name="{$k}" id="attr_{$k}" value="{$v|escape:'htmlall':'UTF-8'}" title="{$v|escape:'htmlall':'UTF-8'}">{$v|escape:'htmlall':'UTF-8'}</option> {/foreach} </optgroup> </optgroup> the in /js/toggle.js add back (it was in the pre 1.5.2 versions) the following function to the beginning of the file: function getE(name) { if (document.getElementById) var elem = document.getElementById(name); else if (document.all) var elem = document.all[name]; else if (document.layers) var elem = document.layers[name]; return elem; } Edited January 3, 2013 by logz05 (see edit history) Link to comment Share on other sites More sharing options...
logz05 Posted January 11, 2013 Author Share Posted January 11, 2013 These are core changes and therefore updating using the 1-click Update to 1.5.3.1 (or beyond) will require that they are re-implemented. Link to comment Share on other sites More sharing options...
mytheory. Posted May 23, 2013 Share Posted May 23, 2013 (edited) Hi, Absolutely wonderful! Thank you very much for this mod! I can confirm this works on PS v.1.5.4.1! I remember implementing this after a lot of hours on our older version, but couldn't remember how to do it. Thank you for saving us time with this necessary mod. I think this should be enabled by default... those with thousands of attribute values like us need this function to save time. Just to add to the topic... we modified the getAttributes() function in the /classes/Attribute.php file. This mod in sql query re-orders the attributes in the generator list by name and not by position. Position may be nice when in order, but with thousands of values to put in order... until we can manage to find time to reorder the list we wanted it ordered as before. At least for us it made it easier to find the values we needed in these long lists. Anyways if you need find the getAttributes() function in the file and modify it as follows: 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' : '').' ORDER BY agl.`name` ASC, al.`name` ASC '); } No really big change; just notice the last line of the query... titled "ORDER BY" HTH! Edited May 23, 2013 by mytheory. (see edit history) Link to comment Share on other sites More sharing options...
cockpitinferno Posted October 28, 2013 Share Posted October 28, 2013 thank you very much. it works good. Link to comment Share on other sites More sharing options...
cockpitinferno Posted April 11, 2014 Share Posted April 11, 2014 it doesnt work with google chrome, anyone would know why? Link to comment Share on other sites More sharing options...
Recommended Posts