Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Insert and Retrive Attributes from custom entity type module
 
yogendrabmishra
Member
 
Total Posts:  34
Joined:  2008-01-22
Bangalore
 

..........

 
Magento Community Magento Community
Magento Community
Magento Community
 
churi
Jr. Member
 
Total Posts:  7
Joined:  2009-04-01
 

Hello,

I want to make a the same thing, did you find an issue?

Thx

 
Magento Community Magento Community
Magento Community
Magento Community
 
churi
Jr. Member
 
Total Posts:  7
Joined:  2009-04-01
 

I also find the solution in this thread

http://www.magentocommerce.com/boards/viewthread/17391/

 
Magento Community Magento Community
Magento Community
Magento Community
 
manchuck
Jr. Member
 
Avatar
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();
 
Magento Community Magento Community
Magento Community
Magento Community
 
jeff_sov
Jr. Member
 
Total Posts:  8
Joined:  2009-12-31
 

Anyone know why some of the posts are empty?

 
Magento Community Magento Community
Magento Community
Magento Community
 
yogendrabmishra
Member
 
Total Posts:  34
Joined:  2008-01-22
Bangalore
 

yeah,

because my crazy bossman made me to delete some of the post from here..

but feel free to ask your questions here and I shall answer you..

Thanks

 
Magento Community Magento Community
Magento Community
Magento Community
 
Brent W Peterson
Moderator
 
Avatar
Total Posts:  3217
Joined:  2009-02-26
Minneapolis MN
 

@Yogendra Mishra::

Do you know if the method addEntityType is available in 1.3?

I get this error when I try to run it.

Fatal errorCall to undefined method Mage_Core_Model_Resource_Setup::addEntityType()
 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top