Jump to content
DaLyR

Get default id category

Recommended Posts

Hi, how I can get the id of the category from the product page? I need a php code, I want to get the ID of the default category in PHP, not in template files of the module.
I need to make some if conditions by using the ID of the default category of the product but I'm unable to get the category id, I searched over all Presta Dev Docs and over all Google results but I don't found the solution, only for tpl files ({$product.category_default}) but as I said, I need to make the condition into the module PHP files, not in TPL.

PS 1.7.6.1

Later edit:// I was able to get the default id of the category, but I don't know if it's a good way

    $cat = new Category($product['id_category_default'], $this->context->language->id);
    $cat->id_category // and then I get the id of the category, default category, from my tests it's ok, but I'm not sure if it's in a right way to get the default category id

 

Edited by RGFMeQ (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