I have question about php classes and scope, Magento in specific. I get the following error, but other methods work,
Fatal error: Call to undefined function getChildCategories()
What syntax is required to make getChildCategories() method work work?
require_once '/var/www/myshop/app/Mage.php';
include "includes/mycompany_report_inventory.php";
Mage::app();
$category_collection = Mage::getModel('catalog/category')
->getCollection()
->addAttributeToSelect('*');
// instantiate and execute inventory report
$mycompany_report_inventory = new mycompany_report_inventory();
$x = $mycompany_report_inventory->GetData($category_collection);
... in file includes/mycompany_report_inventory.php
class mycompany_report_inventory {
function GetData($category_collection){
$this->fnListHierarchy();
}
...
function fnListHierarchy() {
// this works:
$_categories = Mage::helper('catalog/category')->getStoreCategories();
// var_dump this to see an associative array of all categories
$categories = getChildCategories($_categories, true);
// Run this to echo out a DOM
renderCategoriesTree($_categories, true);
}
}