Jump to content

[SOLVED] [PS 1.7] Get product's categories in ProductController


Recommended Posts


I am trying to make some custom changes to breadcrumbs so I'm trying to edit the getBreadcrumbLinks() method in ProductController.php.

What I need is to get IDs from more categories than just the default one. The code which is in the current code is:

$categoryDefault = new Category($this->product->id_category_default, $this->context->language->id);

How can I achieve that? I tried to add a new element in the ProductControllerCore. An array which would take the necessary IDs from Product.php in the init() method. But that didn't go well and I've ran out of ideas how to do it properly.

I would appreciate any help,


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


Use getCategories() function of the product class to get the all categories of the product like

$categories = $this->product->getCategories();

& after that loop through each category using the function which you mentioned to get the name & other details of the categories.

$categoryDefault = new Category($category_id, $this->context->language->id);


  • Like 1
Link to comment
Share on other sites

  • 1 year later...

This is not working for me i have tried


$allcat = $prestashopProductClass->getCategories();

            foreach($allcat as $catdata){
                $categoryDefault = new Category($catdata, 1);


any thoughts on this ?

Link to comment
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...