How to remove subcategories from category URLs

by | Dec 2, 2013 | 0 comments

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:

handbags.com/handbags-all/style/leather-handbags.html

into this:

handbags.com/leather-handbags.html

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

app/code/core/Mage/Catalog/Model/

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

app/code/local/Mage/Catalog/Model/Url.php

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

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

elan creative

We’re like the in-house website design team you always dreamed of, able to tell your story like nobody else, and focus on your bottom line along with you….

Elan Creative
hello@elancreative.studio
UK: +44 (0)121 288 3449
NL: +31 (0)20 893 2923

freelance-website-designer s

INSTANT QUOTE

Get a instant quote for your website design project with our cost calculator:

LATEST DESIGNS

 

dental practice website design

LR Smiles

Website design for brand new dental practice LR Smiles

 

LATEST DESIGNS

 

hypnotherapy website design

 

Nalam Hypnotherapy

Website design for brand new hypnotherapy practice, Nalam Hypnotherapy