0
這是model-> save()後的模型;magento模型不保存所有字段
[_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
但我的數據庫的'字段'和'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字段不...
您是否清除緩存?即使緩存被禁用,表模式仍然被緩存,並且您可能正在使用該模式的過期版本。 – Marius