3

Magento version is 1.9.2.3.

I have tried following solution which doesn't work for me.

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: http://www.abcxyz.com/test-category-level-1-3.html
See more.

I have also tried this solution which doesn't work for me.

Suppose you want to remove parent category path from url such as Url-> 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

Help me if you have another solution

0

When You Override the file Url.php. You just need to edit line number 726 that has below code:

$requestPath = $parentPath . $urlKey . $categoryUrlSuffix;

change it to below code :

$requestPath = $urlKey . $categoryUrlSuffix;

Then update it. No need to edit $parentPath.

Flush Magento cache and it should work.

It worked for me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.