1

I'm organizing my attributes to show in a specific order in layered navigation. To do this I need to set the 'position' value of them all. Magento defaults them to 0 so to put an attribute (say color) at the top of the list, I'll need to change the position of them all, which can get tedious.

What code can I use to reset all my attributes to 100 and to change the defaults?

Bonus: To exclude specific attributes from being reset such as Mage::getResourceModel('catalog/attributes')->excludeFilter(array('color', 'size')->walk('delete');

Note: Changing the default position of a product has already been discussed. I'm looking to change the position of the attribute itself.

Manage Attributes Page

ANSWER: Thank you saravanavelu for your pointer.

Here is the code I was looking for:

UPDATE `catalog_eav_attribute` SET `position`= 100 WHERE `attribute_id` NOT IN (130, 140, 120)

where the numbers are attribute codes. Attribute codes are found in the URL of the Edit Attribute page.

2

Try this to change the position,

//72 is description's attribute id
UPDATE `catalog_eav_attribute` SET `position`= 100 WHERE `attribute_id` = 72
  • Why do you want me to change the attribute called 'description'? – tzvi Aug 3 '15 at 20:36
  • this is for example to change the position – saravanavelu Aug 3 '15 at 20:45
  • I see the table in phpmyadmin. Shouldn't the column name be position? Also would you be able to try for the Bonus. I'm not so great at SQL queries. – tzvi Aug 3 '15 at 21:01
  • I have updated the answer – saravanavelu Aug 3 '15 at 21:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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