Jump to content

[Solved] Altering product's categories in database


Recommended Posts

Hi Guys,


Im looking for a way to see in the database, which all categories a product appears in.

Eg: Product: Apple, category: 1,3,4


I tried searching the database but could not find the right table. In the product table, only the default category shows, it does not show all the categories it appears in.


Someone in my office, moved all the products around and now nothing matches the original categories :((




Edited by phantomeye (see edit history)
Link to comment
Share on other sites

The table is db-prefix_category_product. Maps id_category to id_product (and includes a manual position within the category).


Via the object model:


$product = new Product($id);
$categories = $product->getCategories();


To set them:


$product = new Product($id);
$success = $product->updateCategories(array('1','3','4'))
$product->id_category_default = '3';

Link to comment
Share on other sites

  • 1 year later...




I have problem to add categories to database.

I use multistore and i have parms 

id, parent,date add, date mod, name,desc, metatags 


im trying update tables with:

 "INSERT INTO `ps_category_shop` (

`id_category` ,
`id_shop` ,
'".$row['categories_id']."',  '3', '1'
"INSERT INTO  `ps_category_lang` (
`id_category` ,
`id_shop` ,
`id_lang` ,
`name` ,
`description` ,
`link_rewrite` ,
`meta_title` ,
`meta_keywords` ,
'".$row['categories_id']."',  '3',  '1',  '".$row['categories_name']."','".$row['categories_htc_desc_tag']."' ,  '".$link."', NULL , NULL , NULL
"INSERT INTO  `ps_category` (
`id_category` ,
`id_parent` ,
`id_shop_default` ,
`level_depth` ,
`nleft` ,
`nright` ,
`active` ,
`date_add` ,
`date_upd` ,
`position` ,
 '".$row['categories_id']."',  '".$parent."',  '3',  '".$depth."',  '12','34',  '1',  '".$row['date_added']."',  '".$row['last_modified']."','1','0'
insert into ps_category_group VALUES('".$row['categories_id']."','1');"
after this i use 
to generate nleft and nright columns 
and categories still doesnt works to my shop.
i see them in BO to all shops but in FO doesnt exist
Edited by kylo (see edit history)
Link to comment
Share on other sites

  • 5 months later...

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...