[英]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.