logo

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

Birmingham office:
+44 (0)121 288 3449

 

Amsterdam office:
+31 (0)20 8932923

 

nina@elancreative.studio

How to remove subcategories from category URLs - Elan Creative
3281
post-template,post-template-page-sidebar,post-template-page-sidebar-php,single,single-post,postid-3281,single-format-standard,qode-core-1.3,ctcc-exclude-AN,ajax_fade,page_not_loaded,,pitch child-child-ver-1.0.0,pitch-ver-2.3, vertical_menu_with_scroll,smooth_scroll,side_menu_slide_from_right,grid_1300,blog_installed,wpb-js-composer js-comp-ver-6.3.0,vc_responsive

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:

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

Tags:
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

Leave a Comment: