Skip to content

Instantly share code, notes, and snippets.

@Rokko11
Created August 29, 2013 11:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Rokko11/6376918 to your computer and use it in GitHub Desktop.
Save Rokko11/6376918 to your computer and use it in GitHub Desktop.
How to add foreign key from bundle_option to cms_block
/** @var $installer Mage_Catalog_Model_Resource_Setup */
$installer = $this;
$installer->startSetup();
$installer->getConnection()->addColumn($installer->getTable('bundle/option'), 'block_id',
array(
'nullable' => true,
'unsigned' => true,
'type' => Varien_Db_Ddl_Table::TYPE_INTEGER,
'comment' => 'Foreign key to Block'
)
);
$installer->getConnection()
->addForeignKey($installer->getFkName('bundle/option', 'block_id', 'cms/block', 'block_id'), $installer->getTable('bundle/option'),
'block_id', $installer->getTable('cms/block'), 'block_id',
Varien_Db_Ddl_Table::ACTION_SET_NULL, Varien_Db_Ddl_Table::ACTION_CASCADE
);
$installer->endSetup();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment