ilario Posted January 15 Share Posted January 15 (edited) hello i use prestashop 8.2, product v2, in the filter combinations, i would like to put the attributes in alphabetical order, in the "show dropdown menu" and if possible in the button add a checkbox that selects them all as in the generation of combinations. thanks a lot Edited January 21 by ilario (see edit history) Link to comment Share on other sites More sharing options...
Divine Posted January 21 Share Posted January 21 Hello, you are in the english section of the forum so please translate your message in the appropriate language Link to comment Share on other sites More sharing options...
ilario Posted January 21 Author Share Posted January 21 2 hours ago, Divine said: Hello, you are in the english section of the forum so please translate your message in the appropriate language sorry you're right Link to comment Share on other sites More sharing options...
pallavigodse Posted January 21 Share Posted January 21 Sort attributes alphabetically in the dropdown menu Override or customize the template: Locate the template file that renders the filter combinations dropdown. This is often found in the admin/themes folder or the module's folder. Open the relevant .tpl or .html.twig file. Sort the attribute list before rendering it. For example, in PHP, you can use usort() to order the array of attributes alphabetically. Modify the controller: If the attribute data is retrieved from a controller, modify the query or function to include an ORDER BY clause (for example, ORDER BY name ASC).Cache and Test: After making modifications, clear the PrestaShop cache (under "Advanced Parameters > Performance") and test the attributes are displayed alphabetically. Link to comment Share on other sites More sharing options...
ilario Posted January 21 Author Share Posted January 21 32 minutes ago, pallavigodse said: Sort attributes alphabetically in the dropdown menu Override or customize the template: Locate the template file that renders the filter combinations dropdown. This is often found in the admin/themes folder or the module's folder. Open the relevant .tpl or .html.twig file. Sort the attribute list before rendering it. For example, in PHP, you can use usort() to order the array of attributes alphabetically. Modify the controller: If the attribute data is retrieved from a controller, modify the query or function to include an ORDER BY clause (for example, ORDER BY name ASC).Cache and Test: After making modifications, clear the PrestaShop cache (under "Advanced Parameters > Performance") and test the attributes are displayed alphabetically. hello thank you very much for the answer, I tried to search in the theme folder both default and new-theme, but I did not find the right file. could you tell me if there is a particular module that controls the products/combination section. Link to comment Share on other sites More sharing options...
Webkul Solutions Posted May 16 Share Posted May 16 On 1/21/2025 at 8:41 PM, ilario said: hello thank you very much for the answer, I tried to search in the theme folder both default and new-theme, but I did not find the right file. could you tell me if there is a particular module that controls the products/combination section. To achieve this, you need to make a single line change in the core file. Here is the path below. https://github.com/PrestaShop/PrestaShop/blob/8.2.0/src/Adapter/Attribute/Repository/AttributeRepository.php#L124 You need to replace this line with the code below. ->addOrderBy('al.name', 'ASC') Result: Link to comment Share on other sites More sharing options...
ilario Posted May 16 Author Share Posted May 16 42 minutes ago, Webkul Solutions said: To achieve this, you need to make a single line change in the core file. Here is the path below. https://github.com/PrestaShop/PrestaShop/blob/8.2.0/src/Adapter/Attribute/Repository/AttributeRepository.php#L124 You need to replace this line with the code below. ->addOrderBy('al.name', 'ASC') Result: hi Webkul thanks a lot for the answer, it works but halfway see image, it lists the attributes almost in alphabetical order, but in a strange way Link to comment Share on other sites More sharing options...
musicmaster Posted May 18 Share Posted May 18 Note that on the attribute page (catalog->attributes) you can define the order of the attributes Link to comment Share on other sites More sharing options...
ilario Posted May 19 Author Share Posted May 19 12 hours ago, musicmaster said: Si noti che nella pagina degli attributi (catalog->attributes) è possibile definire l'ordine degli attributi hi thanks for the reply, but the attributes are already in order for the front, but in B.O I need them in alphabetical order to find them faster Link to comment Share on other sites More sharing options...
Webkul Solutions Posted May 19 Share Posted May 19 On 5/16/2025 at 12:31 PM, ilario said: hi Webkul thanks a lot for the answer, it works but halfway see image, it lists the attributes almost in alphabetical order, but in a strange way Can you please share a screenshot of your attribute list in the back office (Instead of product editing)? Link to comment Share on other sites More sharing options...
ilario Posted May 19 Author Share Posted May 19 2 hours ago, Webkul Solutions said: Can you please share a screenshot of your attribute list in the back office (Instead of product editing)? Link to comment Share on other sites More sharing options...
Webkul Solutions Posted May 19 Share Posted May 19 50 minutes ago, ilario said: Thanks for sharing the image. We have checked again at our end & everything is working fine once we implement the changes as we shared with you. Can you please share the code image where you made changes? Link to comment Share on other sites More sharing options...
Ray UK Posted May 19 Share Posted May 19 (edited) 59 minutes ago, ilario said: The attributes in that screenshot are not in order. You need to manually drag them into order using the Cross in the position column, then they will be in order in the B.O and shop view. No code editing is needed Edited May 19 by Ray UK (see edit history) Link to comment Share on other sites More sharing options...
ilario Posted May 19 Author Share Posted May 19 7 minutes ago, Webkul Solutions said: Thanks for sharing the image. We have checked again at our end & everything is working fine once we implement the changes as we shared with you. Can you please share the code image where you made changes? of course , thanks Link to comment Share on other sites More sharing options...
ilario Posted May 19 Author Share Posted May 19 1 minute ago, Ray UK said: The attributes in that screenshot are not in order. You need to manually drag them into order using the Cross in the position column, then they will be in order in the B.O and shop view. Ray UK in front must remain so they are positioned correctly, in front they must not be in alphabetical order, I only need that in B.O. Link to comment Share on other sites More sharing options...
Ray UK Posted May 19 Share Posted May 19 Also, if you are using the latest prestashop, you can enable the "Experimental Product Page" and this has a "Select all" for the combinations. Link to comment Share on other sites More sharing options...
Ray UK Posted May 19 Share Posted May 19 3 minutes ago, ilario said: Ray UK in front must remain so they are positioned correctly, in front they must not be in alphabetical order, I only need that in B.O. Ahh sorry i must have missed that bit. Yes what I suggest will sort them in the Front and Back. Link to comment Share on other sites More sharing options...
ilario Posted May 19 Author Share Posted May 19 2 minuti fa, Ray UK ha detto: Inoltre, se stai utilizzando l'ultimo prestashop, puoi abilitare la "Pagina del prodotto sperimentale" e questa ha un "Seleziona tutto" per le combinazioni. sì grazie lo uso già, è esattamente lì che sto cercando di modificarli e metterli in ordine alfabetico Link to comment Share on other sites More sharing options...
Ray UK Posted May 19 Share Posted May 19 On 5/16/2025 at 7:17 AM, Webkul Solutions said: To achieve this, you need to make a single line change in the core file. Here is the path below. https://github.com/PrestaShop/PrestaShop/blob/8.2.0/src/Adapter/Attribute/Repository/AttributeRepository.php#L124 You need to replace this line with the code below. ->addOrderBy('al.name', 'ASC') Result: Would this change also order the column "Combination"? Or is there a way to add a "Sortable" to that column. It's annoying that when adding a new option, regardless of the name, it's always added to the bottom with no way of sorting them. (Im using the experimental product page) 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