Jump to content

PS 1.6 Category tree no working


Recommended Posts

Hi guys,


I recently created a module that imports some products from a very "special" file, but i still have some issues understanding why are the categories and manufacturers saved in the db.


Describing what i`am doing :


1. After upload, open file, read line i`m constructing a productObject (mine) to help me populate the PS productObject.

2. First i`m creating the category if it not exists also the manufacturer. Save them and retrieve the ids. 

3. Creating the product & save.


I receive no errors and the imports finishes with success, but if i go to a imported product in the Association Tab, that product does not have a manufacturer or a category, even doe in the product listing they are shown ...


If i navigate to categories, the categories exists with all the child's. Even the manufacturers exist ...


I really don`t understand what is wrong ... bellow is a sample of code for adding a category, manufacturer & product.

// Category
$category_to_create = new Category();
$category_to_create->name = $tools->import->createMultiLangField($string);
$category_to_create->active = 1;								

// Default parent is root
$category_to_create->id_parent = ($i == 0) ? Configuration::get('PS_ROOT_CATEGORY') : $return[$i-1]['id_category'];

$category_link_rewrite = Tools::link_rewrite($category_to_create->name[$dLang]);
$category_to_create->link_rewrite = $tools->import->createMultiLangField($category_link_rewrite);

    $rtr['id_category'] = $category_to_create->id;

// Manufacturer
$manufacturer = new Manufacturer();
$manufacturer->name = $myObject->getManufacturer();


$psProduct->id_manufacturer = $$manufacturer->id;
$psProduct->manufacturer_name = $myObject->getManufacturer();


$psProduct->id_category_default = $last_category_added; // Last one of 3 categories
$psProduct->id_category[] = $array_of_added_categories; // Each one has 3 categories


Cristian Nicolae Nicorici

Edited by CristianNC (see edit history)

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More