Skip to content

Instantly share code, notes, and snippets.

@stnc
Created June 8, 2017 11:17
Show Gist options
  • Save stnc/ab5ea2d3c8d61ab1424db951a7deb72e to your computer and use it in GitHub Desktop.
Save stnc/ab5ea2d3c8d61ab1424db951a7deb72e to your computer and use it in GitHub Desktop.
<?php
/* Remove all category */
require_once('app/Mage.php');
ini_set('display_errors', 1);
set_time_limit(0);
Mage::setIsDeveloperMode(true);
Mage::app();
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
$resource = Mage::getSingleton('core/resource');
$db_read = $resource->getConnection('core_read');
$categories = $db_read->fetchCol("SELECT entity_id FROM " . $resource->getTableName("catalog_category_entity") . " WHERE entity_id>2 ORDER BY entity_id DESC");
foreach ($categories as $category_id) {
try {
Mage::getModel("catalog/category")->load($category_id)->delete();
} catch (Exception $e) {
echo $e->getMessage() . "\n";
}
}
exit;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment