Magento – Access Sub-category without Parent Category

categorymagento-1.8

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

Category: http://yoursite.com/category.html

Sub-category: http://yoursite.com/category/sub-category.html

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

Sub-category: http://yoursite.com/sub-category.html

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 ?

Thanks

Best Answer

In Admin:

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

Programmatically:

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

Related Topic