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

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

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

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

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

Sub-category: http://mysite.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

share|improve this question

3 Answers 3

i can recommend you to try below default function

Remove parent category path from url and change it from

http://mysite.com/category/sub-category.html to http://mysite.com/sub-category.html

USAGE :

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 => http://mysite.com/category/sub-category.html

Option NO => http://mysite.com/sub-category.html

Edit

    <global>
        <models>
             <catalog>
                <rewrite>
                    <product_url>YourNamespace_Catalog_Model_Product_Url</product_url>
                </rewrite>
            </catalog>
        </models>
   </global>

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 at 7:10
    
Liyakat is right. –  Amit Bera Jun 26 at 7:24
    
@AmitBera, Thanks –  liyakat Jun 26 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 1.7.0.2 –  Lazar Jun 26 at 12:32
    
What should I do if I see no such option in my Mage admin ? –  Lazar Jun 27 at 4:31

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

share|improve this answer

we made this extension to do it

https://github.com/seansan/snh_settings_CategoryParentUrl

Up+1 if you like it

share|improve this answer

Your Answer

 
discard

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.