Skip to content

Instantly share code, notes, and snippets.

@renorram
Last active September 13, 2016 19:37
Show Gist options
  • Save renorram/0802a21885b5b8f795d00e1b7fbb7144 to your computer and use it in GitHub Desktop.
Save renorram/0802a21885b5b8f795d00e1b7fbb7144 to your computer and use it in GitHub Desktop.
Magento delete categories progamatically
<?php
public function deleteAction(){
// not a good practice
Mage::register("isSecureArea", 1);
//load all categories
$categories = Mage::getModel('catalog/category')
->getCollection()
->addAttributeToSelect('*')
->addIsActiveFilter();
foreach($categories as $category){
if($category->getName() == 'Cal'){
$category->delete();
}
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment