I’m quite new to Magento and had a look around for some modifications we’d like to do to our Magento installation…
Ok, first some more information on what we’re trying to achieve:
we’d like to add a couple of more fields to the registration form, validate them (custom validation - preferrably a call to a function that will return true/false) and store them in the Magento database.
Firstly: I’ve had a look at this Wiki post: http://www.magentocommerce.com/wiki/custom_account/registration_fields, which helped me a lot. It made it possible for me to add a test field to the form and -when overriding the core code- save them in the database. Now, it’s not a good idea to hack it into the core code, so I’d actually love to find a way to override the core code with some local code… I tried to merge the modifications with this Wiki post to customize code: http://www.magentocommerce.com/wiki/groups/174/changing_and_customizing_magento_code#custom_modules, but that’s when it went wrong
* the test field I added is called “myfield” in the code below (attached) and the company is “mycompany”.
* I ran the following code as well:
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$AttrCode = 'myfield';
$settings = array (
'position' => 1,
$setup->addAttribute('1', $AttrCode, $settings);
* the cache is disabled
Then I created a mycompany_All.xml in \app\etc\modules...:
\app\etc\modules => mycompany_All.xml (see attachment for content of file)
Then, I created the following files and folders:
\app\code\local\mycompany\Customer\etc => config.xml (see attachment for content of file)
\app\code\local\mycompany\Customer\Model\Entity => Setup.php (see attachment for content of file)
Clearly it’s got something to do with the way I need to override things properly, since doing the modifications in the core classes (\app\code\core\Mage\Customer\etc.config.xml and \app\code\core\Mage\Customer\Model\Entity\Setup.php) did the trick…
After solving this issue I need to find a way to have custom validation on the fields, but let’s not clutter it too much for now!
Thanks in advance for your help!