nunofc Posted August 2, 2016 Share Posted August 2, 2016 Hello. We have a clothing store based on Prestashop 1.6.1.6, and we noticed an issue that we haven't been able to solve. Example: On the product sheet at back office, the combinations are added in the following order: But in the product sheet on the front office, the drop down menu shows the combinations (in this case for size, as we only have one color per product) messed up: It should show 36, 37, 38, 39... Is there any code we can enter on product.tpl so it shows the attribute in the same order it is added on the product sheet (back office)? I guess this way looks a bit messed up and not clean at all. Thanks in advance for any help. Best regards, Nuno Costa Link to comment Share on other sites More sharing options...
Knowband Plugins Posted August 17, 2016 Share Posted August 17, 2016 The combinations that are shown on the product page are fetched using the getAttributesGroups() function in Product class. This function simply executes a query to extract all the aatributes, you can simply add a ORDER BY clause to achieve this. Link to comment Share on other sites More sharing options...
nunofc Posted August 23, 2016 Author Share Posted August 23, 2016 Hello Knowband Plugins, Thanks for your help. I'm a bit of a newbie when it comes to code editing so: I found the file Product.php in /public_html/classes and found the following line: public function getAttributesGroups($id_lang) Can you please help me on what I should write to Order by alphabetical/numerical order? Thanks in advance and best regards, Nuno Link to comment Share on other sites More sharing options...
joe ramires Posted May 20, 2017 Share Posted May 20, 2017 @nunofc, Try to change: ORDER BY ag.`position` ASC, a.`position` ASC, agl.`name` ASC'; to ORDER BY ag.`position` ASC, al.`name` ASC, a.`position` ASC, agl.`name` ASC'; 1 Link to comment Share on other sites More sharing options...
Israel A Santos Posted September 25, 2017 Share Posted September 25, 2017 (edited) @nunodc To be identical to the admin:1) Access classes\Product.php2) Search for getAttributesGroups (approximately line 3489) ...3) Original code(approximately line 3512):ORDER BY ag.`position` ASC, a.`position` ASC, agl.`name` ASC'; Replace with:ORDER BY ag.`position` ASC, pa.`id_product_attribute` ASC, a.`position` ASC, agl.`name` ASC'; 4) SAVE and be sure to remove the class_index.php file in the cache folder #Prestashop 1.6.x Edited September 25, 2017 by Israel A Santos (see edit history) 1 3 Link to comment Share on other sites More sharing options...
Un_Tal_Iban Posted October 5, 2017 Share Posted October 5, 2017 (edited) Thank you ! Works fine in 1.7.5 Edited December 23, 2018 by tali656 (see edit history) Link to comment Share on other sites More sharing options...
Yarick Posted May 3, 2020 Share Posted May 3, 2020 (edited) In the latest PrestaShop this could be nicely regulated by selecting positions for the Attributes and Attribute Groups. The front office then shows the attributes according to their positions. To fix this in admin I added the following to the classes/Product.php : first query of getAttributesResume diff Product.php.modified Product.php 2323,2325d2322 < 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` 2327,2329c2324 < GROUP BY pa.`id_product_attribute` < ORDER BY ag.`position`,a.`position` < '); --- > GROUP BY pa.`id_product_attribute`'); Edited May 3, 2020 by Yarick (see edit history) Link to comment Share on other sites More sharing options...
frayoubessem Posted December 21, 2021 Share Posted December 21, 2021 On 9/26/2017 at 12:00 AM, Israel A Santos said: @nunodc To be identical to the admin: 1) Access classes\Product.php 2) Search for getAttributesGroups (approximately line 3489) ... 3) Original code(approximately line 3512): ORDER BY ag.`position` ASC, a.`position` ASC, agl.`name` ASC'; Replace with: ORDER BY ag.`position` ASC, pa.`id_product_attribute` ASC, a.`position` ASC, agl.`name` ASC'; 4) SAVE and be sure to remove the class_index.php file in the cache folder #Prestashop 1.6.x thanks ! 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