Jump to content

sort the attributes alphabetically


ilario

Recommended Posts

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

attribute desc.png

Edited by ilario (see edit history)
Link to comment
Share on other sites

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...