Created
June 8, 2017 11:17
-
-
Save stnc/ab5ea2d3c8d61ab1424db951a7deb72e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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