0
我需要的是從.csv文件添加新的類別和子類別。我可以創建新的根類,但我不知道如何使子類別:添加新的類別和子類別 - Magento
$category = Mage::getModel('catalog/category');
$category->setStoreId(0);
$rootCategory['name'] = 'Reserved';
$rootCategory['path'] = "1"; // for root category
$rootCategory['display_mode'] = "PRODUCTS_AND_PAGE";
$rootCategory['is_active'] = 1;
$category->addData($rootCategory);
$parentCategory= $category; // doesn't work, but i want here to get this (root) category id
try {
$category->save();
}
catch (Exception $e){
echo $e->getMessage();
}
CSV文件將被格式化是這樣的:
root_cat_id;subcat_id;subcat_name;subsubcat_id;subsubcat_name;
ex.
1;2;Animal;3;Dog;
我怎麼能得到的只是添加類的ID,並添加與此類別相關的子類別?
在此先感謝