我已经创建了一个自定义模块,使从我的CSV导入静态块
以下代码:
$staticblock = Mage::getModel('cms/block');
$staticblock->load($identifier)->getData();
$staticblock->setData('title', $title);
$staticblock->setData('identifier', $identifier);
$staticblock->setData('content', $content);
$staticblock->setData('creation_time', $creation_time);
$staticblock->setData('update_time', $update_time);
$staticblock->setData('is_active', $is_active);
$staticblock->setData('stores',$store_id);
如果静态块已经具有我的存储id,则报告文件
中显示的错误"a:5:{i:0;s:84:"A block identifier with the same properties already exists in the selected store.bug";i:1;s:1117:"#0 "
我的代码工作良好,如果块与标识符还没有准备好,它将被创建一个新的静态块
$staticblock = Mage::getModel('cms/block')->load($identifier);
if ((!$staticblock) || (!$staticblock->getId())) { //not exists , or try using $staticblock->isObjectNew()
$staticblock->setData('identifier', $identifier);
}
$staticblock->setData('title', $title);
$staticblock->setData('content', $content);
$staticblock->setData('creation_time', $creation_time);
$staticblock->setData('update_time', $update_time);
$staticblock->setData('is_active', $is_active);
$staticblock->setData('stores',$store_id);
查看是否为新对象