mowax Posted August 6, 2013 Share Posted August 6, 2013 (edited) Is it possible to change the display order of the feature values in the layered navigation block? Please see the first attachment, I have a range of thicknesses which I would like to in ascending order. The IDs are not in proper order as I created the feature values over time and not in correct order, as you can see in the second attachment. As you can also see there are no arrows to move the values up/down. Is it possible to edit the IDs in the database or something like that, or will I just have to start again?? Thanks for any ideas Edited August 7, 2013 by duratex (see edit history) Link to comment Share on other sites More sharing options...
PascalVG Posted August 6, 2013 Share Posted August 6, 2013 (edited) I presume you have 'used the attributes already in products (if not, you can just edit the names and change them into increasing values). I think we have to search for a solution in either the database query (as I quickly could see, in modules/blocklayered/blocklayered.php or we have to change the array order just before displaying. Needs some time to sort out, though. Maybe also have a look into this, so we can try to come up with a solution faster. My 2 cents for now, pascal. quick try: find in above mentioned file the function: public function getFilterBlock($selected_filters = array()) scroll down until you see case 'id_attribute_group':// attribute group (the 'case' under 'case manufacturer) case 'id_attribute_group':// attribute group $sql_query['select'] = ' SELECT COUNT(DISTINCT p.id_product) nbr, lpa.id_attribute_group, a.color, 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, id_attribute '; At the end you see ORDER BY id_attribute_group, id_attribute '; change id_attribute into: ORDER BY id_attribute_group, lial '; Not sure if it's correct, just try for a moment :-) pascal Edited August 6, 2013 by PascalVG EDIT: OF course doesn't work, as ORDER BY value is a table name, not a field name :[ . Also, the name wasn't in the Select list. Most of all, as duratex mentioned correctly below, we needed the features, not the attributes (see edit history) Link to comment Share on other sites More sharing options...
mowax Posted August 6, 2013 Author Share Posted August 6, 2013 Hi pascal, Thank you very much for the suggestion. The values are actually features rather than attributes, does it work in a similar way? Cheers Link to comment Share on other sites More sharing options...
PascalVG Posted August 6, 2013 Share Posted August 6, 2013 Ah, you're right of course. Slip of the mind. I think I found it: Just under the code mentioned above (Which didn't work by the way, as I ordered on the table (name), instead of a field , oops, too quick a first try!!! ) You have this code: case 'id_feature': $sql_query['select'] = 'SELECT fl.name feature_name, fp.id_feature, fv.id_feature_value, fvl.value, COUNT(DISTINCT p.id_product) nbr, lifl.url_name name_url_name, lifl.meta_title name_meta_title, lifvl.url_name value_url_name, lifvl.meta_title value_meta_title '; $sql_query['from'] = ' FROM '._DB_PREFIX_.'feature_product fp INNER JOIN '._DB_PREFIX_.'product p ON (p.id_product = fp.id_product) LEFT JOIN '._DB_PREFIX_.'feature_lang fl ON (fl.id_feature = fp.id_feature AND fl.id_lang = '.$id_lang.') INNER JOIN '._DB_PREFIX_.'feature_value fv ON (fv.id_feature_value = fp.id_feature_value AND (fv.custom IS NULL OR fv.custom = 0)) LEFT JOIN '._DB_PREFIX_.'feature_value_lang fvl ON (fvl.id_feature_value = fp.id_feature_value AND fvl.id_lang = '.$id_lang.') LEFT JOIN '._DB_PREFIX_.'layered_indexable_feature_lang_value lifl ON (lifl.id_feature = fp.id_feature AND lifl.id_lang = '.$id_lang.') LEFT JOIN '._DB_PREFIX_.'layered_indexable_feature_value_lang_value lifvl ON (lifvl.id_feature_value = fp.id_feature_value AND lifvl.id_lang = '.$id_lang.') '; $sql_query['where'] = 'WHERE '.$alias.'.`active` = 1 AND fp.id_feature = '.(int)$filter['id_value'].' 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 fv.id_feature_value ORDER BY fvl.value '; // <-- ADD THIS HERE: ORDER BY fvl.value if (!Configuration::get('PS_LAYERED_HIDE_0_VALUES')) { $sql_query['second_query'] = ' SELECT fl.name feature_name, fp.id_feature, fv.id_feature_value, fvl.value, 0 nbr, lifl.url_name name_url_name, lifl.meta_title name_meta_title, lifvl.url_name value_url_name, lifvl.meta_title value_meta_title FROM '._DB_PREFIX_.'feature_product fp '.(version_compare(_PS_VERSION_,'1.5','>') ? Shop::addSqlAssociation('product', 'fp') : '').' INNER JOIN '._DB_PREFIX_.'product p ON (p.id_product = fp.id_product) LEFT JOIN '._DB_PREFIX_.'feature_lang fl ON (fl.id_feature = fp.id_feature AND fl.id_lang = '.$id_lang.') INNER JOIN '._DB_PREFIX_.'feature_value fv ON (fv.id_feature_value = fp.id_feature_value AND (fv.custom IS NULL OR fv.custom = 0)) LEFT JOIN '._DB_PREFIX_.'feature_value_lang fvl ON (fvl.id_feature_value = fp.id_feature_value AND fvl.id_lang = '.$id_lang.') LEFT JOIN '._DB_PREFIX_.'layered_indexable_feature_lang_value lifl ON (lifl.id_feature = fp.id_feature AND lifl.id_lang = '.$id_lang.') LEFT JOIN '._DB_PREFIX_.'layered_indexable_feature_value_lang_value lifvl ON (lifvl.id_feature_value = fp.id_feature_value AND lifvl.id_lang = '.$id_lang.') WHERE '.$alias.'.`active` = 1 AND fp.id_feature = '.(int)$filter['id_value'].' GROUP BY fv.id_feature_value ORDER BY fvl.value '; // <-- ADD THIS HERE : ORDER BY fvl.value } break; Add two times this piece of code: ORDER BY fvl.value just after the group by... code piece. That should do the trick. Note: values like '5' will come AFTER '25', as the values are compared as string, not as value: so first 'digit-characters' are compared: '5' > '2'). To solve this, change 5 into 05 if needed. Then you will get order of 05, 25, ... Let me know if it works for you! pascal 2 Link to comment Share on other sites More sharing options...
mowax Posted August 6, 2013 Author Share Posted August 6, 2013 Many thanks again pascal, I will definitely give this a try! Cheers Link to comment Share on other sites More sharing options...
mowax Posted August 7, 2013 Author Share Posted August 7, 2013 Works great, thank you very much Link to comment Share on other sites More sharing options...
PascalVG Posted August 7, 2013 Share Posted August 7, 2013 You're welcome, good luck with your shop! pascal Link to comment Share on other sites More sharing options...
infinityl Posted November 14, 2013 Share Posted November 14, 2013 In case of attributes instead of features, this works: Toeareg, on 01 Aug 2013 - 08:20 AM, said: **UPDATE**I made some changes to modules/blocklayered/blocklayered.php (lines 2677 & 2709) to make the sort order of the attributevalues work in block layered navigation as well as in the menus.Line 2677, added a.position in the SELECT clause: SELECT COUNT(DISTINCT p.id_product) nbr, lpa.id_attribute_group,a.position, a.color, al.name attribute_name, agl.public_name attribute_group_name , lpa.id_attribute, ag.is_color_group,Line 2709, changed the ORDER BY clause from:ORDER BY id_attribute_group, id_attribute';to:ORDER BY id_attribute_group, position';Now all sorting works like it should You also have to add a.position in the sql query in 2715 and in the order 2742 Link to comment Share on other sites More sharing options...
иван Posted March 12, 2015 Share Posted March 12, 2015 Hello. HELP !!! Need some values The value of the filter navigation leave the default sort (country brand, brands) everything else you need redaktirovati yourself. Prompt possibly do? Link to comment Share on other sites More sharing options...
simberak Posted April 14, 2016 Share Posted April 14, 2016 Hello guys, can anybody help with this problem? I have lot of rings sizes and lot of other and it would be nice to have these attributes sorted from smallest size to the biggest, nomatter the position is in the BO or DB, so literaly order by name, but 5 needs to be smaller then 25, but I cant make it that way Pascal said to change 5 to 05 . And I think I will need it to order just before displaying because I have all the products imported and they are reimported every day... I am also having similar problem at product pages, where I need to order/sort the attributes from smallest/from A to biggest/to Z. My test domain is http://www.webgamesy.cz PS 1.6.1.4 It would be so nice if someone can help with this... Very very thanks for any hint... Daniel Link to comment Share on other sites More sharing options...
Tatooine Posted September 30, 2016 Share Posted September 30, 2016 UP please !! How to do that with PS 1.6.1.6 ? Anyone ? Help needed here ! Link to comment Share on other sites More sharing options...
GrooveWobbler Posted March 15, 2017 Share Posted March 15, 2017 Another way...I wanted to display the price slider first, but otherwise keep the order. It was coming last. In the blocklayered.php, in the case "price" simply add it to the start of the filter_blocks array using unshift. //$filter_blocks[] = $price_array; // move price to top array_unshift($filter_blocks, $price_array); hope that helps someone 1 Link to comment Share on other sites More sharing options...
hakeryk2 Posted May 25, 2017 Share Posted May 25, 2017 UP please !! How to do that with PS 1.6.1.6 ? Anyone ? Help needed here ! Change ORDER BY al.`position` ASC, a.`position` ASC'; to ORDER BY al.`name` ASC, a.`position` ASC'; Link to comment Share on other sites More sharing options...
mrfwappy Posted January 4, 2018 Share Posted January 4, 2018 Hi. Does someone know how to make this work in 1.7? I'd like the Feature Values to be in order of ID, and they seem to be in Alphabetical (by name). Thanks in advance. Link to comment Share on other sites More sharing options...
aleprestasuri Posted April 9, 2018 Share Posted April 9, 2018 (edited) Hello everyone , I need help. I can't order the filter with the above indications. I have followed PascalVG's instructions but they have not worked. I have the versión 1.6.1.17 Prestashop. Can someone help me please? Excuse my spanglish. Edited April 9, 2018 by aleprestasuri Falta información (see edit history) 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