Skip to content

Instantly share code, notes, and snippets.

@deniscsz
Created August 19, 2012 03:55
Show Gist options
  • Save deniscsz/3391790 to your computer and use it in GitHub Desktop.
Save deniscsz/3391790 to your computer and use it in GitHub Desktop.
<?php
$installer = $this;
$installer->startSetup();
$setup = Mage::getModel('customer/entity_setup', 'core_setup');
$setup->addAttribute('customer', 'tipopessoa', array(
'type' => 'int',
'input' => 'select',
'label' => 'Tipo Pessoa',
'global' => 1,
'visible' => 1,
'required' => 0,
'user_defined' => 1,
'default' => '0',
'visible_on_front' => 1,
'source' => 'novoatributo/entity_tipopessoa',
));
$setupRG = Mage::getModel('customer/entity_setup', 'core_setup');
$setupRG->addAttribute('customer', 'rg', array(
'type' => 'varchar',
'input' => 'text',
'label' => 'Identidade (RG)',
'global' => 1,
'visible' => 1,
'required' => 0,
'user_defined' => 1,
'default' => '0',
'visible_on_front' => 1,
));
if (version_compare(Mage::getVersion(), '1.4.2', '>='))
{
Mage::getSingleton('eav/config')
->getAttribute('customer', 'tipopessoa')
->setData('used_in_forms', array('adminhtml_customer','customer_account_create','customer_account_edit','checkout_register'))
->save();
Mage::getSingleton('eav/config')
->getAttribute('customer', 'rg')
->setData('used_in_forms', array('adminhtml_customer','customer_account_create','customer_account_edit','checkout_register'))
->save();
}
$tablequote = $this->getTable('sales/quote');
Mage::log("TABELA ".$tablequote);
$installer->run("
ALTER TABLE $tablequote ADD `customer_tipopessoa` INT NOT NULL
");
$tablequoteRG = $this->getTable('sales/quote');
Mage::log("TABELA RG ".$tablequoteRG);
$installer->run("
ALTER TABLE $tablequoteRG ADD `customer_rg` VARCHAR(10)
");
$installer->endSetup();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment