Magento category list is empty -


i'm adding category using code below.

my question is: how modify code add category root category?

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 category"; $general['meta_title'] = "my category"; //page title $general['meta_keywords'] = "my , category"; $general['meta_description'] = "some description found meta search robots. 2"; $general['is_active'] = 1; $general['is_anchor'] = 0; $general['url_key'] = "cars";//url used category's page magento. $category->adddata($general);  try {     $category->save();     echo "<p>success! id: ".$category->getid(); } catch (exception $e){     echo $e->getmessage(); } 

just add :

$general['path'] = "1/root_id/path_to_your_cat"; 

with path one, example if root category want add category id 5 use :

$general['path'] = "1/5";  

Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -