How to remove subcategories from category URLs

If you want to remove parent categories from the Magento category URLs unfortunately there is no setting for this in Magento admin.

Here’s an example of what we are trying to achieve. We’re trying to change this:

into this:

The solution requires coping a core file and then editing it. To remove subcategories from Magento category URLs go to the following directory:


Copy the Url.php and put it in the following directory (creating any folders where necessary):


Now edit your new file: approx line 716, find this function getCategoryRequestPath($category, $parentPath) {} comment this lines.

Now comment out as follows:

//if (null === $parentPath) { //$parentPath = $this->getResource()->getCategoryParentPath($category); //} //elseif ($parentPath == ‘/’) { $parentPath = ‘ ‘; //(‘Don’t comment it’) //}

Save the file then go to System->Config->Index Management and reindex everything.

This will flatten your Magento category URLs to remove parent categories

Nina Young About the author

I studied mathematics at university, taught myself software development, honed my skills with multinational companies such as IBM and have set up and sold my own businesses. My perspective covers the all important period when a business moves from small and successful to substantial and market-leading, and my personal experience allows me to provide online solutions that give business leaders mastery of their online presence and control over business development.

No Comments

Post a Comment