-
- manchuck

-
Total Posts: 7
Joined: 2009-08-20
|
@Yogendra Mishra
Thank for the great posts. Just a note that I found some helpful functions in the Mage_Eav_Model_Entity_Setup class that make the writing the installer script that much easier:
addEntityType will add the new entity type into the eav_entity_type. This also will update if you run the installer again
createEntityTables Creates all the tables and foreign key constraints for you.
addAttribute Will save on creating that getDefaultEntries method and will add the new attribute for you.
Here is an example that I created
<?php $installer = $this; //This sets MySql variables that will surpress the errors if this is run again $installer->startSetup();
$entType = 'myCompany'; $entId = $installer->addEntityType(entType, array( 'entity_model' => 'myCompany/mopdel', 'attribute_model' => 'myCompany/resource_eav_attribute', 'table' => 'myCompany/table')) ->getEntityTypeId(entType); //create all the tables $installer->createEntityTables(entType);
//Allowed Params for Attributes (see Mage_Eav_Model_Entity_Setup::addAttribute) $settings = array( 'backend' =>'', 'type' =>'varchar', 'table' =>'', 'frontend' =>'', 'input' =>'text', 'input_renderer' =>'', 'label' =>'', 'frontend_class' =>'', 'source' =>'', 'global' =>1, 'visible' =>1, 'required' =>1, 'user_defined' =>0, 'default' =>'', 'searchable' =>0, 'filterable' =>0, 'comparable' =>0, 'visible_on_front' =>0, 'is_html_allowed_on_front' =>0, 'visible_in_advanced_search' =>0, 'used_for_price_rules' =>1, 'filterable_in_search' =>0, 'used_in_product_listing' =>0, 'used_for_sort_by' =>0, 'unique' =>0, 'apply_to' =>'', 'is_configurable' =>1, 'note' =>'', 'position' =>0)
$settings['label'] ='User Name'; $installer->addAttribute($entId, 'user', $settings);
$installer->endSetup();
|