Jump to content

CSV import categories


Recommended Posts

This is what I get importing csv categories

 

[PrestaShopException]

 

Parent category does not exist

at line 380 in file classes/Category.php

 

374. if (!$this->id_parent)

375. return 0;

376.

377. $parent_category = new Category((int)$this->id_parent);

378. if (!Validate::isLoadedObject($parent_category))

379. throw new PrestaShopException('Parent category does not exist');

380. return $parent_category->level_depth + 1;

381. }

382.

383. /**

384. * Re-calculate the values of all branches of the nested tree

  • CategoryCore->calcLevelDepth - [line 156 - classes/Category.php] - [0 Argument]
     
    150. }
    151.
    152. public function add($autodate = true, $null_values = false)
    153. {
    154. if (!isset($this->level_depth))
    155. $this->level_depth = $this->calcLevelDepth();
    156. $ret = parent::add($autodate, $null_values);
    157. if (Tools::isSubmit('checkBoxShopAsso_category'))
    158. foreach (Tools::getValue('checkBoxShopAsso_category') as $id_shop => $value)
    159. {
    160. $position = Category::getLastPosition((int)$this->id_parent, $id_shop);

  • CategoryCore->add - [line 964 - controllers/admin/AdminImportController.php] - [0 Argument]
     
    958. $res = $category->update();
    959. if ($category->id == Configuration::get('PS_ROOT_CATEGORY'))
    960. $this->errors[] = Tools::displayError('Root category cannot be modified');
    961. // If no id_category or update failed
    962. if (!$res)
    963. $res = $category->add();
    964. }
    965. //copying images of categories
    966. if (isset($category->image) && !empty($category->image))
    967. if (!(AdminImportController::copyImg($category->id, null, $category->image, 'categories')))
    968. $this->warnings[] = $category->image.' '.Tools::displayError('cannot be copied');

  • AdminImportControllerCore->categoryImport - [line 2694 - controllers/admin/AdminImportController.php] - [0 Argument]
     
    2688. $this->truncateTables((int)Tools::getValue('entity'));
    2689.
    2690. switch ((int)Tools::getValue('entity'))
    2691. {
    2692. case $this->entities[$this->l('Categories')]:
    2693. $this->categoryImport();
    2694. break;
    2695. case $this->entities[$this->l('Products')]:
    2696. $this->productImport();
    2697. break;
    2698. case $this->entities[$this->l('Customers')]:

  • AdminImportControllerCore->postProcess - [line 158 - classes/controller/Controller.php] - [0 Argument]
     
    152. // setMedia MUST be called before postProcess
    153. if (!$this->content_only && ($this->display_header || (isset($this->className) && $this->className)))
    154. $this->setMedia();
    155.
    156. // postProcess handles ajaxProcess
    157. $this->postProcess();
    158.
    159. if (!empty($this->redirect_after))
    160. $this->redirect();
    161.
    162. if (!$this->content_only && ($this->display_header || (isset($this->className) && $this->className)))

  • ControllerCore->run - [line 348 - classes/Dispatcher.php] - [0 Argument]
     
    342. // Execute hook dispatcher
    343. if (isset($params_hook_action_dispatcher))
    344. Hook::exec('actionDispatcher', $params_hook_action_dispatcher);
    345.
    346. // Running controller
    347. $controller->run();
    348. }
    349. catch (PrestaShopException $e)
    350. {
    351. $e->displayMessage();
    352. }

  • DispatcherCore->dispatch - [line 50 - iadmin/index.php] - [0 Argument]

Link to comment
Share on other sites

I got something similar too. The stack dump is a bit too much... But the message is quite explicit: each category must have a parent category to attach to, and this parent category must exist and probably must be defined first.

I had the error because I kept the parent category 0 (zero) from the export from Zen Cart. Replacing these ids with 1 made it work.

Link to comment
Share on other sites

  • 9 months later...
×
×
  • Create New...