插入磁铁类别不起作用 [英] insert magneto category not working
本文介绍了插入磁铁类别不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我尝试在数据库中插入新类别时没有出现错误,这里没有插入类别是我的代码有什么问题
不是新类别是父类别孩子
$ cat_arr有一些类别
when i try to insert new category in database no error appear and no category inserted here is my code what is wrong
not that the new categories are parent not child
$cat_arr have some categories
try{
$category = Mage::getModel('catalog/category');
foreach ($cat_arr as $cat ) {
$category->setName($cat['shortName']);
$category->setUrlKey($cat['localizedId']);
$category->setIsActive(1);
$category->setDisplayMode('PRODUCTS');
$category->setIsAnchor(1); //for active achor
$category->setDescription($cat['name']);
$category->setStoreId(Mage::app()->getStore()->getId());
$category->setAttributeSetId($category->getDefaultAttributeSetId());
// $parentCategory = Mage::getModel('catalog/category')->load($parentId);
// $category->setPath($parentCategory->getPath());
$category->save();
}
} catch(Exception $e) {
var_dump($e);
}
推荐答案
cat_arr有一些类别
cat_arr have some categories
try{
category = Mage :: getModel('catalog / category');
foreach(
category = Mage::getModel('catalog/category'); foreach (
cat_arr as
cat_arr as
这篇关于插入磁铁类别不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文