Magento属性值未正确保存

时间:2015-04-15 11:27:23

标签: php magento attributes

我正在以编程方式向magento下拉属性添加值。它正确保存字符串值没有问题。但是当添加诸如30或50甚至4D或7D的值时,它不保存包含数字或整数的这些值。我正在使用的代码是:

$arg_attribute = 'size';
    $attr_model = Mage::getModel('catalog/resource_eav_attribute');
    $attr = $attr_model->loadByCode('catalog_product', $arg_attribute);
    $attr_id = $attr->getAttributeId();
    $option['attribute_id'] = $attr_id;

    foreach($size_array as $size) {
        $found = false;
        foreach($options_array_size as $option1) {
            if($size == $option1['label']) {
                $found = true;
                break;
            }
        }

        if(!$found) {
            $option['value'][str_replace(' ','',"$size")][0] = "$size";
        }
    }

$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$setup->addAttributeOption($option);

我在这里做错了吗?我该怎么做才能在属性选项中保存整数值?

0 个答案:

没有答案