Skip to content

Instantly share code, notes, and snippets.

@willboudle
Last active January 2, 2016 13:19
Show Gist options
  • Select an option

  • Save willboudle/8308999 to your computer and use it in GitHub Desktop.

Select an option

Save willboudle/8308999 to your computer and use it in GitHub Desktop.
Create Category Programmatically
Create category dynamically:
$category = Mage::getModel('catalog/category');
$category->setStoreId(Mage::app()->getStore()->getId());
$cat['name'] = "Custom Category Name here";
$cat['path'] = "1/2/30"; //parent relationship..
$cat['description'] = "categorie's description";
$cat['is_active'] = 1;
$cat['is_anchor'] = 0; //for layered navigation
$cat['page_layout'] = 'two_columns_left';
$cat['url_key'] = "custom-category"; //url to access this category
$cat['image'] = "custom-category.jpg";
$category->addData($cat);
$category->save();
Then reindex catalog_category_flat dynamically:
$process = Mage::getSingleton('index/indexer')->getProcessByCode('catalog_category_flat');
$process->reindexEverything();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment