Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
EAV custom entities example Magenot 1 installer script.
<?php
// EAV custom entities example Magenot 1 installer script.
/* @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