Magento setPath for category

Posted by Alan Whitelaw on Stack Overflow See other posts from Stack Overflow or by Alan Whitelaw
Published on 2011-01-13T17:14:07Z Indexed on 2011/01/13 23:53 UTC
Read the original article Hit count: 262

Filed under:
|
|

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

© Stack Overflow or respective owner

Related posts about php

Related posts about magento