I am creating a simple import script for attributes and I cannot figure out how to add options to them. Every attribute of the 'Attribute' is straight forward, except for adding an option. Is this something that can be done upon the creation of an Attribute??
The code I use basically is below.
$model = Mage::getModel('catalog/resource_eav_attribute');
$data = array(
'is_global' => '0',
'frontend_input' => 'text',
'default_value_text' => '',
'default_value_yesno' => '0',
'default_value_date' => '',
'default_value_textarea' => '',
'is_unique' => '0',
'is_required' => '0',
'frontend_class' => '',
'is_searchable' => '1',
'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' => '0',
'used_in_product_listing' => '0',
'used_for_sort_by' => '0',
'is_configurable' => '0',
'is_filterable' => '0',
'is_filterable_in_search' => '0',
'backend_type' => 'varchar',
'default_value' => '',
'frontend_label' => '',
'attribute_code' => ''
);
foreach ($header as $key => $value){
if(isset($data[$key]) !== false){
$data[$key] = $row[$header[$key]];
}
}
$data['option'] = ?WHAT DO I DO HERE¿
$model->addData($data);
$model->setEntityTypeId(Mage::getModel('eav/entity')->setType('catalog_product')->getTypeId());
$model->setIsUserDefined(1);
$model->save();
}
EDIT:
Thanks to Marko for his example, I tried the following;
$data['option'] = array (
'value' => array(
'wood' => array('Wood'),
'metal' => array('Metal')
)
);
His method for adding attributes in general is slightly different but the value for that attribute works just the same.
W00t!