我正在使用下面的代码添加一个类别。
我的问题是:如何修改此代码以将类别添加到根类别?
require_once('../app/Mage.php');
Mage::app('mysite');
$category = Mage::getModel('catalog/category');
$category->setStoreId(Mage::app()->getStore()->getId());
if ($id) {
$category->load($id);
}
$general['name'] = "My Category";
$general['description'] = "Great My Category";
$general['meta_title'] = "My Category"; //Page title
$general['meta_keywords'] = "My , Category";
$general['meta_description'] = "Some description to be found by meta search robots. 2";
$general['is_active'] = 1;
$general['is_anchor'] = 0;
$general['url_key'] = "cars";//url to be used for this category's page by magento.
$category->addData($general);
try {
$category->save();
echo "<p>Success! Id: ".$category->getId();
}
catch (Exception $e){
echo $e->getMessage();
}