0
votes

I wanna make a module by which i can add a field in newsletter_subscriber table in database in magento. Although i have added a field in customer table in past but i am unable to enter the field in news letter table. It always give me error "call to undefined function addAttribute".

I have also try to use Mage_Eav_Model_Entity_Setup in config.xml then there is another error 'wrong entity' appear. i am using following line to add a field.

$installer->addAttribute('newsletter/subscriber', 'city', array( 'type' enter code here => 'varchar', 'label' => 'City', 'visible' => false, 'required' => false ));

Please tell me where i am wrong??

2

2 Answers

0
votes

You can't add eav attribute to newsletter_subscriber table. On the latest magento version you should use

$table = $installer->getTable('newsletter_subscriber');
$table->addColumn('<field>', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
    'unsigned'  => true,
    'nullable'  => false,
    'primary'   => true,
));
0
votes

Here is how to add a custom column to the newsletter_subscriber table in Magento 1.9

$installer = $this;
$installer->startSetup();
$table = $this->getTable('newsletter_subscriber');

$installer->getConnection()
    ->addColumn(
        $table,
        '<field>', array(
            'type'      => Varien_Db_Ddl_Table::TYPE_SMALLINT,
            'nullable'  => true,
            'after'     => null,
            'comment'   => 'Note: the comment is mandatory'
        )
    );

$installer->endSetup();