What is the best method of adding new attributes to the sales and/or quote tables in magento via an install script:

use: addColumn() or use addAttribute() ?

So the main questions are :

What is the best if in the future I need to migrate to a new version (I m on CE 1.7) ? What is the best for performance ?

I need to display this custom data in the admin back end order grid, so what is the best choice for that too (performance & usability) ?

Thank you in advance !

  • This should clear some of the fog: magento.stackexchange.com/q/9751/146 – Marius Nov 12 '13 at 13:40
  • @Marius : Yes I've seen this post (and others) and If I understand well, addAttribute() is link to eav which is not the best for performance, and addColumn() is better for performance but not recommended because you change a core data table (so it can be pain in the ass for a future migration if I understand well). So from personnal experiences what do you recommend ? – Thomas Seres Nov 12 '13 at 13:45
  • I've used addColumn() starting with CE Anyway, addAttribute() it will still add a column to the core table. Starting addAttribute is a wrapper for addColumn in the sales module. That's when the salse tables turned flat. – Marius Nov 12 '13 at 13:48
  • @Marius : thank you for your feedback & informations, really appreciated ! – Thomas Seres Nov 12 '13 at 13:50
  • @ThomasSeres Does that answer your question? – David Manners Nov 15 '13 at 21:18

Just so this question would have an answer.

If you are creating an extension for version and below you need to use addAttribute because the sales objects were EAV up to that version.

For versions starting with you can use both addAttribute and addColumn.
They basically do the same thing for backwards compatibility.

If you don't know the version for which you are developing (or developing for all of them) use addAttribute. It's safer.

And don't worry about performance in the install/upgrade scripts. The scripts are executed only once and you shouldn't make upgrades when the site is live. So you should be the only one that is viewing the website when the upgrade is done.

| improve this answer | |

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.