Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

sql Script is right or wrong? 
 
kelvinkyaw
Jr. Member
 
Total Posts:  3
Joined:  2013-01-29
Myanmar [Burma], Yangon
 

When I add multiple fields in customer registration, i had a error. Please help me!!!

<?php

$installer 
$this;

$installer->startSetup();

$installer->addAttribute('customer_address''govt_id', array(
    
'type' => 'varchar',
    
'input' => 'text',
    
'label' => 'Govt ID NO#',
    
'global' => 1,
    
'visible' => 1,
    
'required' => 0,
    
'user_defined' => 1,
    
'visible_on_front' => 1
));

$installer->addAttribute('customer_address''field_one', array(
    
'type' => 'varchar',
    
'input' => 'text',
    
'label' => 'Field One',
    
'global' => 1,
    
'visible' => 1,
    
'required' => 0,
    
'user_defined' => 1,
    
'visible_on_front' => 1
));


if (
version_compare(Mage::getVersion(), '1.6.0''<='))
{
    $customer 
Mage::getModel('customer/address');
    
$attrSetId $customer->getResource()->getEntityType()->getDefaultAttributeSetId();
    
$this->addAttributeToSet('customer_address'$attrSetId'General''govt_id');
    
$this->addAttributeToSet('customer_address'$attrSetId'General''field_one');
    
}

if (version_compare(Mage::getVersion(), '1.4.2''>='))
{
    Mage
::getSingleton('eav/config')
    ->
getAttribute('customer_address''govt_id')
    ->
getAttribute('customer_address''field_one')
    ->
setData('used_in_forms', array('customer_register_address','customer_address_edit','adminhtml_customer_address'))
    ->
save();
}

$tablequote 
$this->getTable('sales/quote_address');
$installer->run("
ALTER TABLE  
$tablequote ADD  `govt_id` varchar(255) NOT NULL
ALTER TABLE  
$tablequote ADD  `field_one` varchar(255) NOT NULL
"
);

$tablequote $this->getTable('sales/order_address');
$installer->run("
ALTER TABLE  
$tablequote ADD  `govt_id` varchar(255) NOT NULL;
ALTER TABLE  
$tablequote ADD  `field_one` varchar(255) NOT NULL;
"
);

$installer->endSetup();

ERROR SHOW --> Fatal error: Call to a member function getAttribute() on a non-object in /var/www/secondver/app/code/local/Frontiir/Address/sql/address_setup/mysql4-install-0.1.0.php on line xx

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top