0

I would like to add some attributes to a custom table with an install script. But whatever I try it didn't work.

$installer = $this;
$installer->startSetup();
$installer->addAttribute(custom_data, 'street', array( ... )

Magento just showed my an error page that this model doesn't exist. But I have this table in my database. What else am I missing?

1

Try this:

$this->getConnection()->addColumn(
    $installer->getTable('custom_data'),
    'street',
    "VARCHAR(255) NOT NULL DEFAULT ''"
);
1

I usually opt to use the following method in installation scripts. It's much easier and you don't need to know the resource setup methods. It works on all types of Magento tables.

// To add a custom column to the quote item table

 $quoteTable = $this->getTable('sales/quote_item');

$this->run(
    "ALTER TABLE `$quoteTable` ADD test DECIMAL(12,4) DEFAULT NULL COMMENT 'Test';
);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.