Magento Attributes – Why Attribute Codes Have a Maximum Length

attributesdatabasedevelopmenteav

When trying to create attributes, I've discovered that the maximum length of an attribute code is 30 characters. Turns out though, that this is NOT actually some sort of real restriction – it is a completely arbitrary value, defined by

Mage_Eav_Model_Entity_Attribute::ATTRIBUTE_CODE_MAX_LENGTH.

So given that, why is there a restriction at all? And why is the default 30, rather than for instance 255, which is the actual limit of the database column?

PS. If anyone can think of better tags for this question, please update them.

Best Answer

This was almost certainly changed in 1.6 part of adding Oracle support - in Oracle, columns can only be 30 characters long, so lots of Magento attributes got shortened, and I imagine this restriction was added at the same time.

See http://m-chanaan.hr/wp-content/uploads/2013/04/RDBMS_Guide2.pdf for a lot of discussion on this.

Related Topic