Magento Forum

Attributes are not editable after programmatically creation
 
hotbytes
Jr. Member
 
Total Posts:  4
Joined:  2010-11-22
 

Hello community,

I created hundreds of attributes in Magento using this script:

$model Mage::getModel('catalog/resource_eav_attribute');
        
$model->setAttributeCode(strtolower($code));
        
        
$data = array(
            
'entity_type_id'                => Mage::getModel('eav/entity')->setType('catalog_product')->getTypeId(),
            
'is_global'                     => '0',
            
'frontend_input'                => 'multiselect',
            
'default_value_text'            => '',
            
'default_value_yesno'           => '0',
            
'default_value_date'            => '',
            
'default_value_textarea'        => '',
            
'is_unique'                     => '0',
            
'is_required'                   => '0',
            
'frontend_class'                => '',
            
'is_searchable'                 => '0',
            
'is_visible_in_advanced_search' => '1',
            
'is_comparable'                 => '1',
            
'is_used_for_promo_rules'       => '0',
            
'is_html_allowed_on_front'      => '1',
            
'is_visible_on_front'           => '1',
            
'used_in_product_listing'       => '0',
            
'used_for_sort_by'              => '0',
            
'is_configurable'               => '1',
            
'is_filterable'                 => '1',
            
'is_filterable_in_search'       => '1',
            
'default_value'                 => '',
            
'frontend_label'                => $labels,
            
'source'                        => 'eav/entity_attribute_source_table',
            
'is_wysiwyg_enabled'            => '1',
        );
        
        
$model->addData($data);
        
$model->setDefaultValue('');
        
$model->setBackendModel('eav/entity_attribute_backend_array');
        
$model->setBackendType('varchar');
        
$model->setApplyTo(array('simple''grouped''configurable''virtual''bundle''downloadable'));
        
$model->setIsUserDefined(1);
        
$model->setFrontendLabel($labels);    
        
$model->setAttributeSetId(4);
        
$model->setAttributeGroupId(Mage::registry('attributeSetGroupId'));
        
        try 
{
            $model
->save();
        
catch(Exception $ex{
            Mage
::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('An error occured: ' $ex->getMessage()));
        
}

I also created some options for some Attributes manually and assign the attribute to the default attribute-set.
Everything works till here.

Now I create a product and tried to assign an option of one of these attributes but this doesn’t work. All selections are not saved.
If I manually create a multiselect attribute everything works fine.

Is there a function or something that locks the attributes for editing?

Thanks in advance

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top