开发者

Magento setPath for category

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('cata开发者_如何学Golog/category') and ->setPath


I have fixed this. The path should include the category id too. Thanks to Eugene Tulika for the pointer in the right direction.

To confirm the $categories array I should have set up was

$categories[] = array('id' => '23', 'path' => '16/23');
$categories[] = array('id' => '24', 'path' => '16/23/24');
$categories[] = array('id' => '25', 'path' => '16/23/24/25');

Shame I couldn't find any documentation on what to pass to setPath() anywhere.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜