Skip to content

Instantly share code, notes, and snippets.

@tuanphpvn
Last active August 4, 2016 00:57
Show Gist options
  • Save tuanphpvn/7102446cfc7e6b880d59 to your computer and use it in GitHub Desktop.
Save tuanphpvn/7102446cfc7e6b880d59 to your computer and use it in GitHub Desktop.
Delete category with a name #Magento #Category
<?php
$deleteCatByName = function($catname) {
$category = Mage::getModel('catalog/category');
$tree = $category->getTreeModel();
$tree->load();
$ids = $tree->getCollection()->getAllIds();
if ($ids){
foreach ($ids as $id){
$cat = Mage::getModel('catalog/category');
$cat->load($id);
$name = $cat->getName();
if($name === $catname) {
$cat->delete();
}
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment