Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

We have following category and sub-category in our store.



Is it possible to access sub-category listing page using below URL


Case 1 : Access sub-category listing page, even if its main category id disabled

Case 2: Access sub-category listing page without using main category in URL

Also if my product is assigned to any sub-category and set the visibility to Catalog, will it appear on sub-category listing page when its category id disabled ?

How can I achieve this ?


share|improve this question

In Admin:

Admin -> System -> Config -> Catalog -> Search Engine Optimizations -> Use Parent Category Path for Category URLs (set to NO)


Open the class Mage_Catalog_Model_Url and comment the below line

//if (null === $parentPath) {
//    $parentPath = $this->getResource()->getCategoryParentPath($category);
//elseif ($parentPath == '/') {
    $parentPath = '';

under function getCategoryRequestPath($category, $parentPath)

You can always create a local of your file, just in order to avoid over riding the core files

share|improve this answer

we made this extension to do it

Up+1 if you like it

share|improve this answer

i can recommend you to try below default function

Remove parent category path from url and change it from to


Go to the Magento Admin Panel -> System -> Configuration -> Catalog -> Seo Options

Select yes or no from "Use Parent Category Path for Category URLs"

Refresh category url index

Option YES =>

Option NO =>



you can try to rewrite url for category. hope this could be work for you. i am not 100% sure about this modle url rewrite in magento1.7

Hope this will sure help you.

share|improve this answer
Thanks for your response. See my updated question. – Lazar Jun 26 '14 at 7:10
Liyakat is right. – Amit Bera Jun 26 '14 at 7:24
@AmitBera, Thanks – liyakat Jun 26 '14 at 10:30
@liyakat, Use Categories Path for Product URLs set to yes. Can not see the option you said i.e. 'Use Parent Category Path for Category URLs'. Version is – Lazar Jun 26 '14 at 12:32
What should I do if I see no such option in my Mage admin ? – Lazar Jun 27 '14 at 4:31

To remove parent category path from child category url
Rewrite class Mage_Catalog_Model_Url
override method public function getCategoryRequestPath($category, $parentPath) like below

public function getCategoryRequestPath($category, $parentPath)
    $storeId = $category->getStoreId();
    $idPath = $this->generatePath('id', null, $category);
    $suffix = $this->getCategoryUrlSuffix($storeId);

    if (isset($this->_rewrites[$idPath])) {
        $this->_rewrite = $this->_rewrites[$idPath];
        $existingRequestPath = $this->_rewrites[$idPath]->getRequestPath();

    if ($category->getUrlKey() == '') {
        $urlKey = $this->getCategoryModel()->formatUrlKey($category->getName());
    } else {
        $urlKey = $this->getCategoryModel()->formatUrlKey($category->getUrlKey());

    $categoryUrlSuffix = $this->getCategoryUrlSuffix($category->getStoreId());
    // Code commented to remove parent category path from child category path
    //if (null === $parentPath) {
    //$parentPath = $this->getResource()->getCategoryParentPath($category);
    //elseif ($parentPath == '/') {
    $parentPath = '';
    $parentPath = Mage::helper('catalog/category')->getCategoryUrlPath($parentPath,
        true, $category->getStoreId());

    $requestPath = $parentPath . $urlKey . $categoryUrlSuffix;
    if (isset($existingRequestPath) && $existingRequestPath == $requestPath . $suffix) {
        return $existingRequestPath;

    if ($this->_deleteOldTargetPath($requestPath, $idPath, $storeId)) {
        return $requestPath;

    return $this->getUnusedPath($category->getStoreId(), $requestPath,
        $this->generatePath('id', null, $category)

Modified below code

if (null === $parentPath) {
    $parentPath = $this->getResource()->getCategoryParentPath($category);
} elseif ($parentPath == '/') {
    $parentPath = '';


//if (null === $parentPath) {
//    $parentPath = $this->getResource()->getCategoryParentPath($category);
//} elseif ($parentPath == '/') {
    $parentPath = '';
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.