Jump to content

Collapsed Attribute Groups in Generator


Recommended Posts

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 by logz05 (see edit history)
Link to comment
Share on other sites

  • 2 weeks later...
  • 4 months later...

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 by mytheory. (see edit history)
Link to comment
Share on other sites

  • 5 months later...
  • 5 months later...
×
×
  • Create New...