Created
November 8, 2011 20:35
-
-
Save Vinai/1349110 to your computer and use it in GitHub Desktop.
Example EAV setup script using createEntityTables(), installEntities() and addAttribute()
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* @var $installer Mage_Eav_Model_Entity_Setup */ | |
$installer = Mage::getModel('eav/entity_setup', 'default_setup'); | |
$installer->startSetup(); | |
// Example createEntityTables() call | |
$installer->createEntityTables('example_supplier'); | |
// Example installEntities() call | |
$installer->installEntities(array( | |
'supplier' => array( | |
'table' => 'example_supplier', | |
'entity_model' => 'example/supplier', | |
'attributes' => array( | |
'name' => array( | |
'label' => 'Name', | |
'type' => 'varchar', | |
'required' => 1 | |
), | |
'location_code' => array( | |
'label' => 'Location Code', | |
'type' => 'int', | |
'required' => 1 | |
), | |
'valid_from' => array( | |
'label' => 'Valid From', | |
'type' => 'datetime', | |
'required' => 0 | |
) | |
) | |
) | |
)); | |
// Example addAttribute() call | |
$installer->addAttribute('supplier', 'priority', array( | |
'label' => 'Priority', | |
'type' => 'int', | |
'required' => 1, | |
'default' => '10' | |
)); | |
$installer->endSetup(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment