Script to get all category in magento.

External script to Display All category which are created in magento.
Below is the code to display all category.

create new file in root of the magento source and add below code in that file

require_once 'app/Mage.php';
$app = Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
$categoriesArray = Mage::getModel('catalog/category')
->addAttributeToSort('path', 'asc')
$categories = array();
foreach ($categoriesArray as $categoryId => $category) {
if (isset($category['name']) && isset($category['level'])) {
$categories[] = array(
'level' => $category['level'],
'label' => $category['name'] );
echo "<pre>";

Above code will display all categories as below screenshot:

Tags: Magento1,

No comments

Leave a Reply

Your email address will not be published. Required fields are marked *