I recently discovered that this is a right pig to get going. There’s plenty of “solutions” on the interwebs. Many seemingly either don’t work, don’t work as expected, or are complete hacks which makes your extension not modular (i.e; by executing the “addAttribute” function within a template, then removing it once it’s done).
Here’s how I did it. Testing working in Magento 188.8.131.52. Create the following directory structure;
app/code/local/BTS app/code/local/BTS/Customer app/code/local/BTS/Customer/etc app/code/local/BTS/Customer/Model app/code/local/BTS/Customer/Model/Entity app/code/local/BTS/Customer/sql app/code/local/BTS/Customer/sql/bts_customer_setup
Create the file app/code/local/BTS/Customer/etc/config.xml;
0.0.1 1 1 BTS_Customer_Model BTS_Customer BTS_Customer_Model_Entity_Setup
Create the file app/code/local/BTS/Customer/Model/Entity/Setup.php;
Create the file app/code/local/BTS/Customer/sql/bts_customer_setup/mysql4-install-0.0.1.php;startSetup(); $installer->addAttribute('customer', 'samples_ordered', array( 'label' => 'Number of samples ordered', 'type' => 'int', 'input' => 'text', 'visible' => true, 'required' => false, 'position' => 9999, )); $installer->endSetup();
And finally, create the file app/etc/modules/BTS_Customer.xml;
I stopped at this point, as all I needed the new attribute for was for system counting internally. This won't display the attribute on the admin panel though.