Skip to content

Error Invalid method Mage_Customer_Model_Attribute::_getDefaultSourceModel #3055

Closed
@gbgssoftware

Description

@gbgssoftware

Preconditions (*)

1.OpenMage 19.4.18
2.

Steps to reproduce (*)

I use a form that adds fields to customer_address
this is the source:

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

$addressHelper = Mage::helper('customer/address');
$store         = Mage::app()->getStore(Mage_Core_Model_App::ADMIN_STORE_ID);
$eavConfig = Mage::getSingleton('eav/config');

$attributes = array(
    'field1' => array(
        'frontend_label'        => 'field1',
        'label'                 => 'field1',
        'backend_type'          => 'varchar',
        'frontend_input'        => 'text',
        'is_user_defined'       => 1,
        'is_system'             => 0,
        'is_visible'            => 1,
        'is_required'           => 0,
    ),
    'field2' => array(
        'frontend_label'        => 'field2',
        'label'                 => 'field2',
        'backend_type'          => 'varchar',
        'frontend_input'        => 'text',
        'is_user_defined'       => 1,
        'is_system'             => 0,
        'is_visible'            => 1,
        'is_required'           => 0,
    ),
    'select_invoice_type' => array(
        'frontend_label'        => 'Identification for Electronic Invoicing',
        'label'                 => 'Ident Type Billing',
        'backend_type'          => 'text',
        'frontend_input'        => 'select',
        'source'                => 'eav/entity_attribute_source_table',
        'is_user_defined'       => 1,
        'is_system'             => 0,
        'is_visible'            => 1,
        'is_required'           => 0,
  )
);




foreach ($attributes as $attributeCode => $data) {
  $attribute = $eavConfig->getAttribute('customer_address', $attributeCode);
  $attribute->setWebsite($store->getWebsite());
  $attribute->addData($data);
  $usedInForms = array(
      'adminhtml_customer_address',
      'customer_address_edit',
      'customer_register_address',
      'customer_account_create'
  );

  $attribute->setData('used_in_forms', $usedInForms);
  $attribute->save();
}

When logging into magento, I get the following message:

a:5:{i:0;s:227:"Error in file: "/var/www/html/site1_dev1/app/code/community/bbsoftware/NewCustom/sql/bbsoftwarefiscaldata_setup/mysql4-upgrade-4.3.0-4.4.0.php" - Invalid method Mage_Customer_Model_Attribute::_getDefaultSourceModel(Array
(
)
)";i:1;s:918:"#0 /var/www/html/site1_dev1/app/code/core/Mage/Core/Model/Resource/Setup.php(635): Mage::exception()
#1 /var/www/html/site1_dev1/app/code/core/Mage/Core/Model/Resource/Setup.php(431): Mage_Core_Model_Resource_Setup->_modifyResourceDb()
#2 /var/www/html/site1_dev1/app/code/core/Mage/Core/Model/Resource/Setup.php(315): Mage_Core_Model_Resource_Setup->_upgradeResourceDb()
#3 /var/www/html/site1_dev1/app/code/core/Mage/Core/Model/Resource/Setup.php(230): Mage_Core_Model_Resource_Setup->applyUpdates()
#4 /var/www/html/site1_dev1/app/code/core/Mage/Core/Model/App.php(434): Mage_Core_Model_Resource_Setup::applyAllUpdates()
#5 /var/www/html/site1_dev1/app/code/core/Mage/Core/Model/App.php(360): Mage_Core_Model_App->_initModules()
#6 /var/www/html/site1_dev1/app/Mage.php(740): Mage_Core_Model_App->run()
#7 /var/www/html/site1_dev1/index.php(71): Mage::run()
#8 {main}";s:3:"url";s:1:"/";s:11:"script_name";s:10:"/index.php";s:4:"skin";s:7:"default";}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions