magento模型不保存所有字段

时间:2016-03-01 23:21:56

标签: magento

这是我在model-> save();

之后的模型
[_data:protected] => Array
        (
            [entity_id] => 27
            [created_at] => 2016-03-01 23:13:29
            [updated_at] => 2016-03-01 23:13:50
            [name] => 222
            [value] => 222
            [visibility] => 0
            [field] => sponsor
            [page_id] => 21
        )

    [_hasDataChanges:protected] => 
    [_origData:protected] => Array
        (
            [entity_id] => 27
            [created_at] => 2016-03-01 23:13:29
            [updated_at] => 2016-03-01 23:13:29
            [name] => 1234
            [value] => 4321
            [visibility] => 0
            [field] => 
            [page_id] => 0
        )

    [_idFieldName:protected] => entity_id

但在我的数据库'field'和'page_id'列中未保存。这是我保存元素的代码:

 foreach ($sponsors as $key => $value) {

            $value["field"] = $field;
            $value["page_id"] = $page_id;

            //Mage::Log($value);


            if(intval($key) < 0)
            {
                $a = Mage::getModel('cmsattribute/attribute');
                $a->addData($value);
                $a->save();
            }
            else
            {
                $a = Mage::getModel('cmsattribute/attribute')->load($key);
                $a->addData($value);
                $a->save();
            }


            Mage::Log($a);
        }

哪里可以出问题?名字和值更新,update_ar也更新,另外2个字段不...

1 个答案:

答案 0 :(得分:3)

未存储在db中的字段是旧字段还是您创建了新字段。如果是新的,请从var / cache中删除所有文件并尝试再次保存。