phillipjfry Posted August 16, 2008 Share Posted August 16, 2008 I can't get my groups and the attributes inside of them that are on my items to display in any sort of alphebetical order, or at least, not both at the same time.I'm not sure how to explain this but I will try my best.I have groups 123In group 1 i have attributes 1, 2, 3. In group 2 I have attributes 1, 2, 3. In group 3 i have attributes 1, 2, 3.If i do not alter my products.php in the prestashop/classes directory the group order displays randomly, but the attributes inside stay in 1, 2, 3 order.If i alter my products.php (line 1317 - 1332) from public function getAttributesGroups($id_lang) { return Db::getInstance()->ExecuteS(' SELECT ag.`id_attribute_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.`id_product_attribute`, pa.`quantity`, pa.`price`, pa.`ecotax`, pa.`weight`, pa.`id_image`, pa.`default_on`, pa.`reference` FROM `'._DB_PREFIX_.'product_attribute` pa LEFT JOIN `'._DB_PREFIX_.'product_attribute_combination` pac ON pac.`id_product_attribute` = pa.`id_product_attribute` 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` LEFT JOIN `'._DB_PREFIX_.'attribute_group_lang` agl ON ag.`id_attribute_group` = agl.`id_attribute_group` WHERE pa.`id_product` = '.intval($this->id).' AND al.`id_lang` = '.intval($id_lang).' AND agl.`id_lang` = '.intval($id_lang).' ORDER BY pa.`id_product_attribute`'); } to public function getAttributesGroups($id_lang) { return Db::getInstance()->ExecuteS(' SELECT ag.`id_attribute_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.`id_product_attribute`, pa.`quantity`, pa.`price`, pa.`ecotax`, pa.`weight`, pa.`id_image`, pa.`default_on`, pa.`reference` FROM `'._DB_PREFIX_.'product_attribute` pa LEFT JOIN `'._DB_PREFIX_.'product_attribute_combination` pac ON pac.`id_product_attribute` = pa.`id_product_attribute` 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` LEFT JOIN `'._DB_PREFIX_.'attribute_group_lang` agl ON ag.`id_attribute_group` = agl.`id_attribute_group` WHERE pa.`id_product` = '.intval($this->id).' AND al.`id_lang` = '.intval($id_lang).' AND agl.`id_lang` = '.intval($id_lang).' ORDER BY ag.`id_attribute_group`'); } (changed line 1331 from ORDER BY pa.`id_product_attribute` to ORDER BY ag. 'id_attribute_group' )the groups will list alphabetically, but the attributes inside do not list alphabetically, in fact it seems almost random in which the order is.I guess what i'm asking is if there is any way to list both my groups and attributes alphabetically at the same time, and how would i do so? Sorry if this is confusing, I will clarify if I need to do so.Thanks for the help! Link to comment Share on other sites More sharing options...
phillipjfry Posted August 18, 2008 Author Share Posted August 18, 2008 Anyone? Link to comment Share on other sites More sharing options...
Paul C Posted August 18, 2008 Share Posted August 18, 2008 phillip,Did you try : ORDER BY ag.id_attribute_group, pa.id_product_attribute');Paul Link to comment Share on other sites More sharing options...
phillipjfry Posted August 18, 2008 Author Share Posted August 18, 2008 Thanks for the reply paul c.I hadn't tried that, but when i change my product.php with the code you posted above, it makes even the main page of my site load up completely blank. Am I not doing something correctly? Or is it just causing errors. Link to comment Share on other sites More sharing options...
phillipjfry Posted August 18, 2008 Author Share Posted August 18, 2008 I figured it out thanks to your input paul ORDER BY ag.`id_attribute_group`, a.`id_attribute`'); works perfectly! Thank you again for the help sir! Link to comment Share on other sites More sharing options...
Paul C Posted August 18, 2008 Share Posted August 18, 2008 Sorry, had a problem with the forum mangling the quotes, so I left them out..... maybe should have mentioned it Great you've got it working.Paul Link to comment Share on other sites More sharing options...
psychosonicsid Posted August 21, 2008 Share Posted August 21, 2008 Hi I am trying to get a similar order : 1 Attribute group by agl. name and the attributes within the group by the al. name but each time i alter the order by line I get a blank page - I have tried the quotes but still get a problem. Any ideas?ThxPsychosonicsid Link to comment Share on other sites More sharing options...
phillipjfry Posted August 21, 2008 Author Share Posted August 21, 2008 Hi I am trying to get a similar order : 1 Attribute group by agl. name and the attributes within the group by the al. name but each time i alter the order by line I get a blank page - I have tried the quotes but still get a problem. Any ideas?ThxPsychosonicsid Hey psychosonicsid. I was trying to do the same thing and was encountering the same error. The code I used above which im going to post again below works perfectly for me. It sorts the groups by name a-z and the attributes a - z, which i think is what your wanting it to be doing. Make a backup and give it a try and see if it works. I could personally never get the agl. things to work myself, not sure why. But again, the code below worked for me so it may for you as well.ORDER BY ag.`id_attribute_group`, a.`id_attribute`); Good luck and while i'm not the most skilled coder, i will try and help you get it working. Link to comment Share on other sites More sharing options...
psychosonicsid Posted August 22, 2008 Share Posted August 22, 2008 Already tried that - blank screen when replacing with the code listed:Ideally I want to sort the attribute groups by the name used in the backoffice, not the public name and the attributes within these by the name of the attribute its self (a-z - 1.-9 etc)Other than this one line there wasnt any other changes that I missed was there?? Link to comment Share on other sites More sharing options...
phillipjfry Posted August 22, 2008 Author Share Posted August 22, 2008 Odd. The way that i have it working it sorts based on the private name, not public so it should be what your looking for. I don't believe I changed anything else but i may have, so i rared up my product.php so you can try upping it to your server and see if it works. Other than that, i can't say what is wrong. Perhaps clearing your cache might do something?http://www.bordnet.net/product.rar Link to comment Share on other sites More sharing options...
psychosonicsid Posted August 23, 2008 Share Posted August 23, 2008 Thanks for this - it works jusss foine!No idea where the problem was - but hey its done, dusted, onward and forward...Many thanks againPsid Link to comment Share on other sites More sharing options...
guyk Posted March 2, 2009 Share Posted March 2, 2009 Thanks, Excellent contribution, This change deserve to be standard. Link to comment Share on other sites More sharing options...
Recommended Posts