我正在处理一些我以编程方式创建多选属性及其选项的东西。我还需要以编程方式从multiselect属性中删除一个选项。 为了创造目的,我使用了这个流程
$attribute_model = Mage::getModel('eav/entity_attribute');
$attribute_code = 11;
$attribute = $attribute_model->load($attribute_code);
$value['option'] = array('some_data');
$result = array('value' => $value);
$attribute->setData('option',$result);
$attribute->save();
但是,当我尝试以相同方式删除选项时,它不起作用。我正在尝试以下代码。
$attribute_model = Mage::getModel('eav/entity_attribute');
$attribute_code = 11;
$attribute = $attribute_model->load($attribute_code);
$value['option'] = array('some_data');
$result = array('value' => $value);
$attribute->unsetData('option',$result); // attempt 1
$attribute->unsetData('some_data'); //attempt 2
$attribute->save();
我尝试了1和2但没有结果。 我该怎么做?
修改
print_r($attribute->getData());
给了我这个结果。
Array
(
[attribute_id] => 133
[entity_type_id] => 4
[attribute_code] => test_attr
[attribute_model] =>
[backend_model] => eav/entity_attribute_backend_array
[backend_type] => varchar
[backend_table] =>
[frontend_model] =>
[frontend_input] => multiselect
[frontend_label] => Tags For Promo
.
.
[frontend_input_renderer] =>
[is_global] => 0
[is_wysiwyg_enabled] => 0
[is_used_for_promo_rules] => 1
)