Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get Parent Category Id in Sub Category Page - Magento

Tags:

php

magento

I need a small line of code. I have a category like

  • Cat-1
    • Sub-Cat-1
    • Sub-Cat-2
  • Cat-2
    • Sub-Cat-3
    • Sub-Cat-4

In Sub-Cats page i need to get Root category's Id. Like In "Sub-Cat-1" i need to get "Cat-1's" ID. You can say in children category page, i need parent category's Id. act i am using short url like "abc.com/Sub-Cat-1", nither index.php nor root category in URL. I am using Magento-1.4.1. Please help me. Thanks in advance.

like image 793
Abhi Avatar asked Dec 16 '22 21:12

Abhi


1 Answers

I got the solution.

echo $cat_idd = $this->getCurrentCategory()->getParentCategory()->getId(); 
like image 55
Abhi Avatar answered Dec 29 '22 03:12

Abhi