Skip to main content

Magento Tip: Move an Attribute to Another Attribute Group and Adjust Display Order

When working with Magento's EAV model, it's common to reorganize attributes across different attribute sets or groups — especially when customizing product forms in the admin panel. Here's a quick tip on how to move an attribute to the same group as another attribute and place it right next to it.

Let’s say you have:

  • An attribute with attribute_id = 689 in the right place (correct group and order).

  • An attribute with attribute_id = 2228 that you want to move to the same group, and display just below the first one.

You can use the following SQL to do exactly that:

UPDATE eav_entity_attribute T1
JOIN (
  SELECT T2.attribute_set_id, T2.attribute_group_id, T2.sort_order
  FROM eav_entity_attribute T2
  WHERE T2.attribute_id = 689 AND T2.entity_type_id = 4
) AS sub ON sub.attribute_set_id = T1.attribute_set_id
SET
  T1.attribute_group_id = sub.attribute_group_id,
  T1.sort_order = sub.sort_order + 1
WHERE T1.entity_type_id = 4 AND T1.attribute_id = 2228;

 

Bonus: Clean Up Sort Order Collisions

To avoid overlapping sort orders with other attributes in the same group, you can shift the sort order for attributes that come after your insertion point:

UPDATE eav_entity_attribute
SET sort_order = sort_order + 1
WHERE attribute_id NOT IN (2228, 689)
  AND sort_order > 10 AND sort_order < 250;

 

Tip: Always back up your database before running direct SQL updates, especially when modifying core EAV tables.