【发布时间】:2015-04-23 13:17:06
【问题描述】:
我正在使用 magento API,需要为不同的商店视图创建下拉选项。
我找到了一个为默认商店视图创建下拉选项的函数:
public function addAttributeOption($arg_attribute, $arg_value)
{
$attribute_model = Mage::getModel('eav/entity_attribute');
$attribute_options_model= Mage::getModel('eav/entity_attribute_source_table');
$attribute_code = $attribute_model->getIdByCode('catalog_product', $arg_attribute);
$attribute = $attribute_model->load($attribute_code);
$attribute_table = $attribute_options_model->setAttribute($attribute);
$options = $attribute_options_model->getAllOptions(false);
$value['option'] = array($arg_value,$arg_value);
$result = array('value' => $value);
$attribute->setData('option',$result);
$attribute->save();
}
这个函数很好用,我可以为默认的 storeview 添加一个新的属性值。
例子:
我有属性“mycolor”并像这样调用函数
addAttributeOption("mycolor", "black")
现在我有一家德国商店的商店视图,并且喜欢设置德国颜色。我需要类似的东西
addAttributeOption("mycolor", "black", "schwarz", $storeview)
表示将storeview的颜色选项设置为schwarz,默认值为黑色。
有人知道我该怎么做吗?
最好的问候
【问题讨论】:
-
好的,没有办法的时候我会通过mysql查询解决。