Here is small Suggession:
<?php
ini_set('max_execution_time', 0);
ini_set('display_errors', 1);
ini_set("memory_limit","1024M");
include('../urls.php');
include('../dbw.php');
$mageFilename = MAGE_FILE_URL_STAGING;
require_once $mageFilename;
Varien_Profiler::enable();
Mage::setIsDeveloperMode(true);
umask(0);
Mage::app('admin');
function get_categories(){
$i = 0;
$category = Mage::getModel('catalog/category');
$tree = $category->getTreeModel();
$tree->load();
$ids = $tree->getCollection()->getAllIds();
$arr = array();
if ($ids){
foreach ($ids as $id){
$category = Mage::getModel('catalog/category');
$category->load($id);
$categorydata = array (
'name' => htmlspecialchars($category->getName(),ENT_QUOTES),
'categorydes' => htmlspecialchars($category->getDescription(),ENT_QUOTES),
'image' => $category->getImageUrl(),
'metakeywords' => htmlspecialchars($category->getmeta_keywords(),ENT_QUOTES),
'metadescrption' => htmlspecialchars($category->getmeta_description(),ENT_QUOTES),
'magento_category_id' => $category->getId(),
'magento_cat_spenish_id' => $category->getId(),
'spanish_name' => htmlspecialchars($category->getName(),ENT_QUOTES),
'parent_id' => $category->getparentId(),
'images' => $category->getImageUrl()
);
echo "<pre>";
print_r($categorydata);
echo "<pre>";
$add = add_categories($categorydata);
$i = $i+1;
}
}
return $arr;
}
$arr = get_categories();
function add_categories($parentid)
{
// echo "INSIDE CATEGORY<br>";
$query = "INSERT INTO `categories` (`id`, `name`, `categorydes`, `image`, `metakeywords`, `metadescrption`, `magentoparentid`, `magento_category_id`, `magento_cat_spenish_id`, `spanish_name`, `updatedateandtime`, `status`)
VALUES (NULL,
'$parentid[name]',
'$parentid[categorydes]',
'$parentid[image]',
'$parentid[metakeywords]',
'$parentid[metadescrption]',
'$parentid[parent_id]',
'$parentid[magento_category_id]',
'$parentid[magento_category_id]',
'$parentid[name]',
CURRENT_TIMESTAMP,
'1')";
mysql_query($query) or die(mysql_error());
// echo $parentid['image']."<br>";
// if($parentid['image'] != "")
// $imagecopy = copyimgto_local($parentid['image']);
}