I need to re-order / sort the attributes on product detail page.

They are sorted with there attribute_id but I don´t want to delete and recreate them.

I know that the attributes can be sorted for the layered navigation with a Position value in Storefront Properties settings but it´s about the position in catalog product view > additional tab.

I´m not sure why I couldn´t find any answer somewhere but there should be some simple solution for this?

I would be very grateful for any hint

3 Answers 3


enter image description here

Do you mean this tab? You want to reorder, for example 'Pattern' to be first in the list? If so, you could override Magento_Catalog::product/view/attributes.phtml in your theme, and add custom logic inside the foreach statement. Maybe add all attributes to a new array but in the order you need, and after that loop through them and output on the frontend

  • Hi Dan thank you for your quick reply.
    – guest123
    Jan 26, 2022 at 6:56
  • that is exactly what I'm looking for. Do you know if there is some way to use the mentioned Position in Storefront Properties(for the layered navigation)? If yes, could you please provide some example with the foreach statement: <?php foreach ($_additional as $_data) :?>
    – guest123
    Jan 26, 2022 at 7:16

If I understand correctly, you would want to add a specific separate position for each attribute, which would be used for rendering on product description page, not just to sort them in alphabetical order? If just to sort in alphabetical order, you could do something like <?php ksort($_additional) ?> before the foreach statement, and it would sort in ascending order by key for example https://www.w3schools.com/php/php_arrays_sort.asp But, if you want to have a position that you can set in the admin panel, inside the form, it gets more complicated. You would have to add a Data Patch for adding a new position Storefront Property for the attribute, different from the existing one, so it does not get mixed with the layered navigation position. Then update the admin form so you can set the value for specific property. Then, you would update the collection and setOrder by this new property.

  • Hi Dan, thank you for your suggestions. For my purpose it would be perfect to use the existing sorting position for the layered navigation. As for the position in the layered nav I use a extension to do the sorting. Do you have any suggestion related to the existing layered navigation position and the use with the foreach statement?
    – guest123
    Jan 27, 2022 at 17:27

For a lot of attributes the sorting with the sorting positions/field for layered nav could be helpful, but usually what I tried to achieve is very easy to do by sorting the product attributes in Attribute Sets. Why make the whole thing so complicated.

@Dan thank you again for your suggestions, efforts and your replies they can maybe help someone else ;)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.