How can i get all categories Id selected by Root Category

2018-01-24 07:31:36

I have three root category, i need all categories id for only selected root categories how can i get it. what are all the possible way to get it?

load($categoryId) ?>

getChildrenCategories() ?>

0): ?>

  • getName() ?>

    load($_category->getId()) ?>

    hasChildren()):?>

    getChildrenCategories() ?>

  • load($categoryId) ?>

    getChildrenCategories() ?>

    0): ?>

    2018-01-24 08:21:47
  • Please try below code. It's very simple.

    error_reporting(E_ALL);

    ini_set("display_errors", 1);

    $mageFilename = 'app/Mage.php';

    require_once $mageFilename;

    Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);

    function convert_to_csv($input_array) {

    /** open raw memory as file, no need for temp files */

    $today = date('Ymd');

    $file_path = "var/catgory_ids" . $today . ".csv";

    $temp_memory_backup = fopen($file_path, 'w');

    fwrite($temp_memory_backup, $input_array);

    fclose($temp_memory_backup);

    echo 'Data saved to csvfile.csv';

    }

    $catid = 2;

    $sub_categories = Mage::getModel('catalog/category')->load($catid)->getChildrenCategories()->getAllIds();

    $data = array();

    $headers = array();

    $header['cat_id'] = 1;

    foreach ($sub_categories as $i => $category) {

    $data[$i]['cat_id'] = $category;

    }

    $tmp_columns = array();

    foreach ($header as $head => $v) {

    $tmp_columns[] = $head;

    }

    $output.= implode(",", $tmp_columns) . "\n";

    //bu

    2018-01-24 08:26:34