只展示一级目录的导入
$root_cate_id = 2;
if (!$this->existsCate(trim($row['mid']))) {
$cate = new Mage_Catalog_Model_Category();
$cate->setName($name);
$cate->setUrlKey(trim($row['mid']));
$cate->setIsActive(1);
$parentCategory = Mage::getModel('catalog/category')->load($root_cate_id);
$cate->setPath($parentCategory->getPath());
$cate->save();
var_dump($name);
unset($cate);
}
删除所有目录
public function removeAllCategory() {
$cat = Mage::getModel('catalog/category')->load(2);
$subcats = $cat->getChildren();
foreach(explode(',',$subcats) as $subCatid)
{
$_category = Mage::getModel('catalog/category')->load($subCatid);
$_category->delete();
}
}