Jump to content
RGFMeQ

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

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