1

I have tried every tutorial on the internet , I have asked questions here and got some good answers which I have accepted and followed. I have created modules, altered core files , installed various versions of magento , but it doesn't matter what I do I cant get anything I DO TO STORE IN THE DATABASE!

I just want to be able to created a custom field on the new account form and store it in the database, I don't care where ?

David Nehme
  • 21,379
  • 8
  • 78
  • 117
Ledgemonkey
  • 7,223
  • 12
  • 36
  • 56
  • possible duplicate of [Magento - Add attribute to customer entity](http://stackoverflow.com/questions/6717241/magento-add-attribute-to-customer-entity) – Adam Rackis Dec 08 '11 at 05:57

4 Answers4

2

I had same problem and it is being caused by using uppercase letter in your attribute name.

If you use only lowercase letters everything gets saved just fine.

Peter
  • 36
  • 2
0

When I haved this problem was becaus was missing code like this

$installer->addAttribute("empresas", "email", array(
    "type" => "varchar",
    "backend" => "",
    "label" => "Email",
    "input" => "text",
    "source" => "",
    "visible" => true,
    "required" => true,
    "default" => "",
    "frontend" => "",
    "unique" => false
));

$attribute = Mage::getSingleton("eav/config")->getAttribute("empresas", "email");


$used_in_forms = array();

$used_in_forms[] = "adminhtml_empresas";

$attribute->setData("used_in_forms", $used_in_forms)
        ->setData("is_used_for_customer_segment", false)
        ->setData("is_system", 0)
        ->setData("is_user_defined", 0)
        ->setData("is_visible", 1)
        ->setData("sort_order", 100)
;
$attribute->save();

in my setup script after $installer->installEntities();

Eliut Islas
  • 588
  • 4
  • 14
0

Make a setup script like this:

<?php

$installer = $this;
$installer->startSetup();

$eav = new Mage_Eav_Model_Entity_Setup('core_setup');

$eav->addAttribute('customer', 'my_property', array(
    'label'     => 'My Property',
    'type'      => 'varchar',
    'input'     => 'text',
    'visible'   => true,
    'required'  => true,
    'position'  => 1,
));

$installer->endSetup();

Then you should be able to add the my_property as an input on the New Customer form.

More on EAV at Alan Storm's Blog

Max
  • 8,671
  • 4
  • 33
  • 46
  • I can add the my_property to the eav attribute , using scripts like this, no problem , I can add nice forms to the front end and put the right code in place , but nothing ever saves to the database , I have tried everything this is doing my nut in , I dont understand why ?? it seems so simple , – Ledgemonkey Dec 07 '11 at 15:32
0

Check these MySQL tables to make sure you're new EAV attribute has been inserted properly. The attribute name should be in eav_attribute with all the atrribute settings and a new attribute_id. The new attribute_id should be in new records in these 3 tables: customer_eav_attribute, customer_eav_attribute_website, customer_form_attribute.

In customer_eav_attribute,customer_eav_attribute_website make sure the is_visible field is set to 1.

If all this checks out, report back with dumps of the 4 new rows I just mentioned so we can check for anything else that might be wrong in the DB. I just recently added new attributes on Magento 1.6.1 and I was nearly tearing my hair out but got it working in the end.

georgiecasey
  • 21,793
  • 11
  • 65
  • 74
  • thanks for your help and sorry for the delay in replying i have had to go and have a new wig fitted !!! – Ledgemonkey Dec 07 '11 at 21:47
  • the new attribute id's are in eav_attribute and customer_eav_attribute but not in the others and are visible, there are no records in the _website table ?? One of my attempts i did manage to get the id in the _form_arrribute table (see link) http://screencast.com/t/es5o3CApIDwn http://screencast.com/t/tujQ48spW http://screencast.com/t/onF5tA5Na i hope you can help !!! thanks again – Ledgemonkey Dec 07 '11 at 22:14
  • `customer_form_attribute` looks fine, `customer_eav_attribute` looks fine. I was wrong, you only need `customer_eav_attribute_website` if it's a multiple store. What version of Magento are you using? Are any of the schools, childsname or flavour fields being saved? – georgiecasey Dec 08 '11 at 00:11
  • 1.6.1 , no they don't save , should they save to customer_entity_varchar ? what about the _form table ? I also have a utility that searches the whole database for records so i know that they are not saving ? thanks – Ledgemonkey Dec 08 '11 at 08:54
  • Yea, I'm on 1.6.1 as well and varchar attribute value saves to `customer_address_entity_varchar`. What _form table you talking about, ` customer_form_attribute`? That has no values, just the 4 references with the new attribute id and form codes: adminhtml_customer_address, customer_address_edit and customer_register_address. What's your module config.xml look like? – georgiecasey Dec 08 '11 at 19:25