Post by 3zzy » Sat Oct 01, 2016 9:10 pm

I'm trying to import categories into the DB directly. So I have an array of categories like so:

Code: Select all

[1] => Array
        (
            [category_id] => 14308
            [parent_id] => 14308
            [level] => 0
        )

    [2] => Array
        (
            [category_id] => 179836
            [parent_id] => 14308
            [level] => 1
        )

        [3] => Array
            (
                [category_id] => 230022
                [parent_id] => 179836
                [level] => 2
            )
I can insert them in the DB easily, but the category_to_path is tricky, just can't figure out how to create multiple rows of path_ids.

This is what I have so far:

Code: Select all

$path_ids;
for ($i=0; $i <= ($category->CategoryLevel-1); $i++) { 
// -1 cause the API returns a non zero-based level

  $path_ids[$i]['category_id'] = $category->CategoryID;

  if ($category->CategoryLevel-1 == $i) {
    $path_ids[$i]['path_id'] = $category->CategoryParentID[0];
  }
  elseif ($category->CategoryLevel-1) {
    // ?
  }

  $path_ids[$i]['level'] = $i;

}
Thanks!

Newbie

Posts

Joined
Thu Aug 11, 2016 12:56 pm
Who is online

Users browsing this forum: Google [Bot] and 8 guests