ProsjektX Posted April 22, 2012 Share Posted April 22, 2012 What do I have to change in blocklayered.php to have it sort attributes? Found a solution for 1.8.0 and features but 1.8.3 is coded differently Link to comment Share on other sites More sharing options...
doubleD Posted April 26, 2012 Share Posted April 26, 2012 What do I have to change in blocklayered.php to have it sort attributes? Found a solution for 1.8.0 and features but 1.8.3 is coded differently Hi, To sort attributes by name: In blocklayered.php find [ about line 2614] ORDER BY id_attribute_group, id_attribute '; Replace with ORDER BY agl.`id_attribute_group`, al.`name` ASC'; Tested on prestashop 1.4.7 and block layered 1.8.3 1 Link to comment Share on other sites More sharing options...
ProsjektX Posted April 29, 2012 Author Share Posted April 29, 2012 Hi, To sort attributes by name: In blocklayered.php find [ about line 2614] ORDER BY id_attribute_group, id_attribute '; Replace with ORDER BY agl.`id_attribute_group`, al.`name` ASC'; Tested on prestashop 1.4.7 and block layered 1.8.3 Thanks for pointing me in the right direction. Also found I could add a "+0" to sort more correctly combinations of numeric and text for instance for values like '50 cm', '70 cm', '100 cm' cause normally '100 cm' would then show first. ORDER BY agl.`id_attribute_group`, al.`name`+0 ASC'; If others would need that too.. 1 Link to comment Share on other sites More sharing options...
doubleD Posted April 29, 2012 Share Posted April 29, 2012 Also found I could add a "+0" to sort more correctly combinations of numeric and text for instance for values like '50 cm', '70 cm', '100 cm' cause normally '100 cm' would then show first. ORDER BY agl.`id_attribute_group`, al.`name`+0 ASC'; And thank you! Need that too ... Link to comment Share on other sites More sharing options...
onico0 Posted May 29, 2013 Share Posted May 29, 2013 Here, the code to sort by POSITION $sql_query['select'] = ' SELECT COUNT(DISTINCT p.id_product) nbr, lpa.id_attribute_group, a.color, a.position, al.name attribute_name, agl.public_name attribute_group_name , lpa.id_attribute, ag.is_color_group, liagl.url_name name_url_name, liagl.meta_title name_meta_title, lial.url_name value_url_name, lial.meta_title value_meta_title'; $sql_query['from'] = ' FROM '._DB_PREFIX_.'layered_product_attribute lpa INNER JOIN '._DB_PREFIX_.'attribute a ON a.id_attribute = lpa.id_attribute INNER JOIN '._DB_PREFIX_.'attribute_lang al ON al.id_attribute = a.id_attribute AND al.id_lang = '.$id_lang.' INNER JOIN '._DB_PREFIX_.'product as p ON p.id_product = lpa.id_product INNER JOIN '._DB_PREFIX_.'attribute_group ag ON ag.id_attribute_group = lpa.id_attribute_group INNER JOIN '._DB_PREFIX_.'attribute_group_lang agl ON agl.id_attribute_group = lpa.id_attribute_group AND agl.id_lang = '.$id_lang.' LEFT JOIN '._DB_PREFIX_.'layered_indexable_attribute_group_lang_value liagl ON (liagl.id_attribute_group = lpa.id_attribute_group AND liagl.id_lang = '.$id_lang.') LEFT JOIN '._DB_PREFIX_.'layered_indexable_attribute_lang_value lial ON (lial.id_attribute = lpa.id_attribute AND lial.id_lang = '.$id_lang.') '; $sql_query['where'] = 'WHERE a.id_attribute_group = '.(int)$filter['id_value']; if (version_compare(_PS_VERSION_,'1.5','>')) $sql_query['where'] .= ' AND lpa.`id_shop` = '.(int)Context::getContext()->shop->id; $sql_query['where'] .= ' AND '.$alias.'.active = 1 AND p.id_product IN ( SELECT id_product FROM '._DB_PREFIX_.'category_product cp INNER JOIN '._DB_PREFIX_.'category c ON (c.id_category = cp.id_category AND '.(Configuration::get('PS_LAYERED_FULL_TREE') ? 'c.nleft >= '.(int)$parent->nleft.' AND c.nright <= '.(int)$parent->nright : 'c.id_category = '.(int)$id_parent).' AND c.active = 1)) '; $sql_query['group'] = ' GROUP BY lpa.id_attribute ORDER BY id_attribute_group, a.position '; 1 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