sgtbash Posted June 1, 2010 Share Posted June 1, 2010 Hi All,Just updated my first of 5 shops to 1.3 and noticed that my attributes are now ordered in alphabetical order and not by the order entered as in 1.2.5.This is great for most attributes, but makes a Small/Medium/Large/X Large/XX Large list look horrible putting large first.Where has the change been made? and can it be reversed?Dan Link to comment Share on other sites More sharing options...
pol2 Posted June 14, 2010 Share Posted June 14, 2010 did you find any solution? I'm the same as you... Link to comment Share on other sites More sharing options...
sgtbash Posted June 14, 2010 Author Share Posted June 14, 2010 Nope, it still is ordered like this:LargeMediumSmallX LargeXX LargeI've got no idea how to solve it =( Link to comment Share on other sites More sharing options...
Timothy Jarman Posted July 2, 2010 Share Posted July 2, 2010 Try this out - http://www.presto-changeo.com/attribute-modules/24-attribute-order.htmlWorks flawless, i just brought this literally 2 mins ago, installed and bobs your uncle. Simple drag and order.He has some really great other modules too, i think he should work for prestashop Link to comment Share on other sites More sharing options...
pasko Posted July 2, 2010 Share Posted July 2, 2010 Hi, You are right I have it and it's a real easy and effective module!Regards. Link to comment Share on other sites More sharing options...
justme54s Posted August 2, 2010 Share Posted August 2, 2010 Hi All,Just updated my first of 5 shops to 1.3 and noticed that my attributes are now ordered in alphabetical order and not by the order entered as in 1.2.5.This is great for most attributes, but makes a Small/Medium/Large/X Large/XX Large list look horrible putting large first.Where has the change been made? and can it be reversed?Dan This is bugging me out, anyone found a solution to this. I don't want to install a module for this. Would appreciate it if someone can point me in the right direction. Thanks Link to comment Share on other sites More sharing options...
justme54s Posted August 30, 2010 Share Posted August 30, 2010 **SOLVED* Hi sgtbash and everyone else looking for the same solution. The attribute order of 1.3 can be reversed back to the order as in 1.2.5. To do this make the following changes;1. In /classes/Product.php function: getAttributesGroups()replace ORDER BY al.`name`'); with ORDER BY pa.`id_product_attribute`'); 2. In /product.phpcomment out the following on lines 285 and 286 foreach($groups AS &$group) natcasesort($group['attributes']); to // foreach($groups AS &$group) // natcasesort($group['attributes']); Please Note: The order of attributes is the order in which you add them to each product. I will soon post a more elegant solution where you can set the order of the attributes in each group in the back office. 1 Link to comment Share on other sites More sharing options...
marcelolopez Posted September 24, 2010 Share Posted September 24, 2010 Thank you justme54s !!!It solved my problem too !!! I just been playing with Prestashop for a couple of days now, and it looks very promising !!Your help is very much appreciated !!Marcelo. Link to comment Share on other sites More sharing options...
classyjoes Posted October 20, 2010 Share Posted October 20, 2010 HELP!I tried the above but when I changed them and uploaded them my homepage goes completely blank.I'm not sure if this matters but the lines that are supposed to be replaced, there is a space missing between foreach and the bracket. I.e. when you search:foreach($groups AS &$group)natcasesort($group['attributes']);it can't find it, so you have to search for the same with a space, as in:foreach ($groups AS &$group)natcasesort ($group['attributes']);I'm new to Prestashop, but I thought I followed this pretty closely Link to comment Share on other sites More sharing options...
Jeet Kune Do Posted October 26, 2010 Share Posted October 26, 2010 Hi everyone.First of all thank's to justme54s! It work's form me. I think we all expecting your promised module.Meanwhile I attached the two modified files. Just replace it, and it's done. You will have the sort order by ID. In my case (s, m, l, xl, xxl).Don't forget! The order of attributes is the order in which you add them to each product.Replace the first file (Product.php) in root/classes/product.phpReplace the second file (product.php) in root/product.phpIt's coded in prestashop version 1.3.2. Older versions are not tested! classyjoes, indeed It have some space errors, so you can download the two file attached and it will work for you. product.php Product.php Link to comment Share on other sites More sharing options...
kpargoiip4 Posted December 17, 2010 Share Posted December 17, 2010 @ Jeet Kune Do ... Worked great, thank you!! Link to comment Share on other sites More sharing options...
hups Posted January 10, 2011 Share Posted January 10, 2011 HelloI have pretashop version 1.3.5 and tried to make the changes as suggested on here but i get a blank page. I downloaded the files and compared to make sure all spacing was correct etc and as far as im concerned they are exactly the same as suggested on here.Could this be anything to do with me having a newer version? Or any ideas what I may be doing wrong please?thanksRob Link to comment Share on other sites More sharing options...
FireHawk Posted February 8, 2011 Share Posted February 8, 2011 I too get a blank page.Messed about for ages to get it back to normal.Can someone comment what could be going wrong here?I am using the 1.3.6.0 version btw. Link to comment Share on other sites More sharing options...
Bacalaomen Posted March 3, 2011 Share Posted March 3, 2011 Hi,Who solved this? I have the same problem.Ths Link to comment Share on other sites More sharing options...
Dishpet Posted March 12, 2011 Share Posted March 12, 2011 Thank-You Very, Very much for posting a fix for the funky attributes order issue justme54s and to Jeet Kune Do for posting the files!! I have been struggling with this attribute order for dang near half a day now and your fix seems to be working for me so far. I am running PrestaShop v.1.3.7 and so far I have not run across any errors.So again I applaud you for finding a fix for the attribute order. Link to comment Share on other sites More sharing options...
Bacalaomen Posted March 22, 2011 Share Posted March 22, 2011 Hi Dishpet,How do you solvet this? I make the changes but I get a blank page. I am using with V.1.3.7. Can you help me please?Ths Link to comment Share on other sites More sharing options...
synkro Posted March 29, 2011 Share Posted March 29, 2011 In version 1.4 you have to change in classes/Product.php on line 2136: ORDER BY agl.`public_name`, al.`name`'); to ORDER BY agl.`id_attribute_group`, al.`name`'); and the same modifications must be made in classes/Cart.php, on line 420, for the attributes to be sorted in the same way in the shopping cart. Link to comment Share on other sites More sharing options...
AMA1MD Posted April 17, 2011 Share Posted April 17, 2011 In version 1.4 you have to change in classes/Product.php on line 2136:ORDER BY agl.`public_name`, al.`name`);toORDER BY agl.`id_attribute_group`, al.`name`);and the same modifications must be made in classes/Cart.php, on line 420, for the attributes to be sorted in the same way in the shopping cart. Only changing this line in the 1.4 will not disappear me 01. 02. etc.Thanks in advance Link to comment Share on other sites More sharing options...
synkro Posted April 19, 2011 Share Posted April 19, 2011 In version 1.4 you have to change in classes/Product.php on line 2136:ORDER BY agl.`public_name`, al.`name`);toORDER BY agl.`id_attribute_group`, al.`name`);and the same modifications must be made in classes/Cart.php, on line 420, for the attributes to be sorted in the same way in the shopping cart. Only changing this line in the 1.4 will not disappear me 01. 02. etc.Thanks in advance The solution that I was reffering to doesn't require adding numbers before the name of the attribute, it will sort the attributes by the order they were added in BO. Link to comment Share on other sites More sharing options...
AMA1MD Posted April 19, 2011 Share Posted April 19, 2011 The problem is that I'm adding to csv and I was not properly organized.The combinations are dates in format 01-01-2011 02-01-2011.Prestashop organize:01-01-201101-02-201101-03-2011 Link to comment Share on other sites More sharing options...
phunter121 Posted April 28, 2011 Share Posted April 28, 2011 I'm going nuts with this, I have made this change, but PS refuses to change the sort order. I have even submitted the SQL to phmysqladmin to check it works. Any ideas why ? Link to comment Share on other sites More sharing options...
phunter121 Posted May 7, 2011 Share Posted May 7, 2011 Synkro, did you resolve this?I understood your original post as a problem with sorting the options (Small, Med, Large Xlarge etc). They currently appear alphabetically (i.e. Large, Med, Small, Xlarge) which is untidy.Do the remaining posts address this issue, or has the post moved onto the sort over of the attributes. I.e. if a product has more than pne set of options.I tried the 1.4 code change and it does not solve the problem mentioned in the original post - the options must be getting sorted again further on. Link to comment Share on other sites More sharing options...
phunter121 Posted May 7, 2011 Share Posted May 7, 2011 OK, I figured this out for v 1.4. The answer was pretty much here, but in 1.4 some of the code has movedTo sort the options within a product drop down menu, you need to comment out the following code in controllers/productController.phpforeach($groups AS &$group)natcasesort($group['attributes']);Also, within product.php, make the change mentioned earlier ie.Change "ORDER BY agl.`public_name`, al.`name`" to the sort order you need. I changed it to "ORDER BY ag.`id_attribute_group`, pa.`price`, pa.`weight`" so that the options are displayed in price order (if the prices are the same, then they will order by weight).This suited my site, but could do any other order you like. Link to comment Share on other sites More sharing options...
chienandalu Posted May 24, 2011 Share Posted May 24, 2011 I was implementing this and yet don't see the point of sorting by `id_attribute_group` since it's going to be always the same id for any given attribute group. What I made at last (somebody correct me if I'm missing something) is to sort that query by al.`id_attribute`. The only condition necesary here is to have the attributes created in our desired order, wich is the usual procedure. Link to comment Share on other sites More sharing options...
phunter121 Posted May 25, 2011 Share Posted May 25, 2011 Good point, ignore that part of the query Link to comment Share on other sites More sharing options...
jesusruiz Posted June 23, 2011 Share Posted June 23, 2011 Does anyone know how to make the attributes appear in the same order in which the insert in the BO?I am using Prestashop 1.4.2 and no way to get it. Link to comment Share on other sites More sharing options...
JAKCRABBIT Posted October 23, 2011 Share Posted October 23, 2011 http://www.prestashop.com/forums/topic/138240-razeni-atributu-smlxlxxl-14/ solved 1.4+ Link to comment Share on other sites More sharing options...
Peha Posted November 1, 2011 Share Posted November 1, 2011 Another way to do this : add a smarty modifier in tools/smarty/plugins to sort any array in your tpl : {foreach from=$groups|sortby"name" key=id_attribute_group item=group} OR with more control {foreach from=$groups|sortby"-name, #id" key=id_attribute_group item=group} The '-' lets you sort in reverse order, and the # lets you sort numerically rather than as a string (you can have '-#id' as well to sort numerically in reverse order) you just need to add this file in tools/smarty/plugins modifier.sortby.php Link to comment Share on other sites More sharing options...
zigojacko Posted February 14, 2012 Share Posted February 14, 2012 Another way to do this : add a smarty modifier in tools/smarty/plugins to sort any array in your tpl : {foreach from=$groups|sortby"name" key=id_attribute_group item=group} OR with more control {foreach from=$groups|sortby"-name, #id" key=id_attribute_group item=group} The '-' lets you sort in reverse order, and the # lets you sort numerically rather than as a string (you can have '-#id' as well to sort numerically in reverse order) you just need to add this file in tools/smarty/plugins The code you included, is not even contained in your attached file. Where do we configure the lines of code you specified please? Thanks Link to comment Share on other sites More sharing options...
gsdealer Posted February 29, 2012 Share Posted February 29, 2012 (edited) In version 1.4 you have to change in classes/Product.php on line 2136: ORDER BY agl.`public_name`, al.`name`'); to ORDER BY agl.`id_attribute_group`, al.`name`'); and the same modifications must be made in classes/Cart.php, on line 420, for the attributes to be sorted in the same way in the shopping cart. Hi, I tried this in ps1.4.7.0 but it did not help $result = Db::getInstance()->ExecuteS(' SELECT pac.`id_product_attribute`, agl.`public_name` AS public_group_name, al.`name` AS attribute_name FROM `'._DB_PREFIX_.'product_attribute_combination` pac LEFT JOIN `'._DB_PREFIX_.'attribute` a ON a.`id_attribute` = pac.`id_attribute` LEFT JOIN `'._DB_PREFIX_.'attribute_group` ag ON ag.`id_attribute_group` = a.`id_attribute_group` LEFT JOIN `'._DB_PREFIX_.'attribute_lang` al ON (a.`id_attribute` = al.`id_attribute` AND al.`id_lang` = '.(int)$id_lang.') LEFT JOIN `'._DB_PREFIX_.'attribute_group_lang` agl ON (ag.`id_attribute_group` = agl.`id_attribute_group` AND agl.`id_lang` = '.(int)$id_lang.') WHERE pac.`id_product_attribute` IN ('.implode($paImplode, ',').') ORDER BY agl.`id_attribute_group`, al.`name` ASC'); the last line was changed (nearby, referencing code line numbers > in mine it was on line #470) sort order still L, M, S, XL,... also, I'm still confused about setting the order by id_attribute_group - is it the group which get sortet or are this the attributes themself? however, I tried all what I found here and in a previous 1.3 post, the attribute sort order did not change. any idea to fix this without buying a module? Thanks from Vienna Tom UPDATE: I gave it a try directly in phpmyadmin which gave me a correct sortorder with the following sql: SELECT ag.id_attribute_group, ag.is_color_group, agl.name AS group_name, agl.public_name AS public_group_name, a.id_attribute, al.name AS attribute_name, a.color AS attribute_color, pa . * FROM ps9gs3ka_product_attribute pa LEFT JOIN ps9gs3ka_product_attribute_combination pac ON pac.id_product_attribute = pa.id_product_attribute LEFT JOIN ps9gs3ka_attribute a ON a.id_attribute = pac.id_attribute LEFT JOIN ps9gs3ka_attribute_group ag ON ag.id_attribute_group = a.id_attribute_group LEFT JOIN ps9gs3ka_attribute_lang al ON a.id_attribute = al.id_attribute LEFT JOIN ps9gs3ka_attribute_group_lang agl ON ag.id_attribute_group = agl.id_attribute_group WHERE pa.id_product =10 AND al.id_lang =4 AND agl.id_lang =4 ORDER BY agl.id_attribute_group, a.id_attribute ; so I went back in code in /classes/product.php and /classes/cart.php adding ORDER BY agl.id_attribute_group, a.id_attribute ; But in Frontend the order is still the same. any idea, if I did the changes in the wrong places? Thanks Tom Edited February 29, 2012 by gsdealer (see edit history) Link to comment Share on other sites More sharing options...
gsdealer Posted March 2, 2012 Share Posted March 2, 2012 Sort Order of attributes (german: Sortierung von Varianten und Kombinationen zb. Größe s, m. l, xl...) Solved with this post also in v 1.4.7.0 I translate: in /classes/Product.php search for: public function getAttributesGroups below that code find the line: ORDER BY ag.`id_attribute_group`, pa.`id_product_attribute`'); in my case it was on line 1217 and change it to: ORDER BY ag.`id_attribute_group`, pa.`id_product_attribute`'); then in /controllers/ProductController.php search for: foreach ($groups AS &$group) natcasesort($group['attributes']); in my case it was on line 327-328 and comment these 2 lines ( // foreach ($groups AS &$group) // natcasesort($group['attributes']); ) Thanks to JAKCRABBIT 1 Link to comment Share on other sites More sharing options...
steviger Posted March 28, 2012 Share Posted March 28, 2012 @gsdealer. I'm using 1.4.5.1 and I think your solution might work. However I see the same line twice: ORDER BY ag.`id_attribute_group`, pa.`id_product_attribute`'); So replace a line with another identical line ? Must be a typo error. Could you help me out? Cheers, Steven Link to comment Share on other sites More sharing options...
paroled Posted May 2, 2012 Share Posted May 2, 2012 pls del, sorry Link to comment Share on other sites More sharing options...
pureclothings Posted May 22, 2012 Share Posted May 22, 2012 Hi everyone. First of all thank's to justme54s! It work's form me. I think we all expecting your promised module. Meanwhile I attached the two modified files. Just replace it, and it's done. You will have the sort order by ID. In my case (s, m, l, xl, xxl). Don't forget! The order of attributes is the order in which you add them to each product. Replace the first file (Product.php) in root/classes/product.php Replace the second file (product.php) in root/product.php It's coded in prestashop version 1.3.2. Older versions are not tested! classyjoes, indeed It have some space errors, so you can download the two file attached and it will work for you. worked perfectly. thanx alot for the fix Link to comment Share on other sites More sharing options...
SuperCharlie Posted June 8, 2012 Share Posted June 8, 2012 Thank you gsdealer. Your fix worked for me. To be clear, change ORDER BY ag.`id_attribute_group`, pa.`id_product_attribute`'); to '); in the first edit an the second edit as listed. I had to try a couple times to get that first one right. Thanks again SC Link to comment Share on other sites More sharing options...
mrzoom Posted June 10, 2012 Share Posted June 10, 2012 I just wanted you to know that they have added attribute postion in prestashop 1.5. So you can drag attributes and groups around without any extra modules or code changes Link to comment Share on other sites More sharing options...
bfreeman Posted October 9, 2012 Share Posted October 9, 2012 (edited) I have changed the code to successfully change the order of the attribute *groups*, but still am not able to change the order of the actual attributes *within* a group (for example: S, M, L, XL, in the "Size" group). Any ideas? I have tried everything mentioned here and in other posts, but still cannot change the order of the attributes themselves. Version 1.4.6.2. THANKS! http://www.professio.../6-macbook.html *I am using a module called "Improved Attributes Selection", which may be the reason the code changes I have made are not working. Hmmmm..... Frustrated and stuck. Any help would be greatly appreciated. UPDATE: solved it, which is amazing considering my very limited programming knowledge:) Wooooooo hooooooooo!! :) Edited October 10, 2012 by bfreeman (see edit history) Link to comment Share on other sites More sharing options...
andrej981 Posted April 19, 2017 Share Posted April 19, 2017 Hi. I have a problem with sorting product attribute. In BO size is list in order that I added it with combination generator. But in front ofice attributes are not in same order like in BO. Problem is that if I choose size which I already add for product before, prestashop place ¨"old" size first and then new created size. But only in FO in BO they are just like they have to be. Examlpe: BO 100 x 100cm (add second) BO 110 x 110cm (add first) FO 110 x 110cm (add first) FO 100 x 100cm (add second) My prestashop version is 1.6.1.4. Can someone please help me with this? 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