繁体   English   中英

Magento无法使用商店ID保存静态块

[英]Magento could not save static block with store id

我已经创建了一个自定义模块,可以从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);

如果静态块已经具有我的商店标识,那么错误将显示在我的报告文件中

"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);

尝试查看它是否是新对象。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM