1
votes

I want to remove subcategory from category url, like http://localhost.com/cat-1/cat-2/ => http://localhost.com/cat-2/

can any one help? FYI : i am working on Magento EE 1.13.1.0

i tried by override app/code/core/Mage/Catalog/Model/Url.php file this not solved my issue.

2

2 Answers

4
votes

I find the following way to remove localhost/testmagento/index.php/parent/child.html to localhost/testmagento/index.php/child.html

step 1. Go to app/code/core/Mage/Catalog/Model/Url.php copy this file to app/code/local/Mage/Catalog/Model/Url.php because it is core Magento file so that we have to copy that file into the app/code/local.

Step 2: Now search for the getCategoryRequestPath($category, $parentPath) around line 698 in Magento ver. 1.9.1.0

Step 3: Search if (null === $parentPath) around line 717 and comment the line as below:

/* if (null === $parentPath) {
$parentPath = $this->getResource()->getCategoryParentPath($category);
}
elseif ($parentPath == '/'){*/
$parentPath = ''; //DO NOT Comment this line
//} 

Step 4: Now Go to the Magento admin and Clear Cache System->Cache Management and Reindex System->Index Management the data.

Step 5: Refresh your browser cache and navigate again now you will see only the Sub Category in Url not the Parent Category just like as

Let me know if you have any query

2
votes

In 1.13 there is an option to use categories path for product urls but there is no option to remove categories paths from category urls

So, i've created a simple module to workaround this.

https://github.com/alitopaloglu/ExcParentCatPathFromSubCatUrls

ATTENTION - DEVELOPED FOR ONLY MAGENTO ENTERPRISE EDITION v1.13

This module adds a yes/no option labelled as "Use Parent Category Path for Category URLs" on

Magento Admin Panel -> System -> Configuration -> Catalog -> Seo Options

to remove parent category path from url and change it from www.domain.com/cat1/cat2 to www.domain.com/cat2

USAGE :

  1. Go to the Magento Admin Panel -> System -> Configuration -> Catalog -> Seo Options
  2. Select yes or no from "Use Parent Category Path for Category URLs"
  3. Refresh category url index

Option YES => www.domain.com/cat1/cat2

Option NO => www.domain.com/cat2