Magento setPath for category
- by Alan Whitelaw
I am using PHP to set up my categories in Magento 1.4.2
$categories[] = array('id' => '23', 'path' => '16');
$categories[] = array('id' => '24', 'path' => '16/23');
$categories[] = array('id' => '25', 'path' => '16/23/24');
foreach ($categories as $category) {
$current_category = Mage::getModel('catalog/category')
->load($category['id'])
->setPath('1/2/'.$category['path'])
->save();
}
However something has gone wrong
The categories have been imported like this:
root
-23
-16
--24
and 25 is nowhere to be seen
Have I got something wrong with my logic or how to use Mage::getModel('catalog/category') and ->setPath